Skip to main content
Glama

mcp-server-kubernetes

by Flux159
configmap.yaml6.68 kB
{{- if eq (include "mcp-server-kubernetes.needsInitContainer" .) "true" }} apiVersion: v1 kind: ConfigMap metadata: name: {{ include "mcp-server-kubernetes.fullname" . }}-scripts labels: {{- include "mcp-server-kubernetes.labels" . | nindent 4 }} {{- $commonAnnotations := include "mcp-server-kubernetes.annotations" . }} {{- if $commonAnnotations }} annotations: {{- $commonAnnotations | nindent 4 }} {{- end }} data: {{- if eq .Values.kubeconfig.provider "aws" }} fetch-aws-kubeconfig.sh: | #!/bin/sh set -e echo "Fetching AWS EKS kubeconfigs..." # Retry configuration MAX_RETRIES=${MAX_RETRIES:-3} RETRY_DELAY=${RETRY_DELAY:-10} export KUBECONFIG=/kubeconfig/kubeconfig touch $KUBECONFIG # Function to retry commands retry_command() { local cmd="$1" local description="$2" local attempt=1 while [ $attempt -le $MAX_RETRIES ]; do echo "Attempt $attempt/$MAX_RETRIES: $description" if eval "$cmd"; then echo "✓ Success: $description" return 0 else if [ $attempt -eq $MAX_RETRIES ]; then echo "✗ Failed after $MAX_RETRIES attempts: $description" return 1 fi echo "⚠ Attempt $attempt failed, retrying in ${RETRY_DELAY}s..." sleep $RETRY_DELAY fi attempt=$((attempt + 1)) done } {{- range .Values.kubeconfig.aws.clusters }} # Fetch cluster: {{ .name }} AWS_CMD="aws eks update-kubeconfig --name {{ .clusterName | quote }} --region {{ .region | quote }}{{- if .roleArn }} --role-arn {{ .roleArn | quote }}{{- end }}{{- if .assumeRoleArn }} --assume-role-arn {{ .assumeRoleArn | quote }}{{- end }} --kubeconfig $KUBECONFIG{{- range .extraArgs }} {{ . | quote }}{{- end }}" retry_command "$AWS_CMD" "Fetching EKS cluster {{ .name }}" {{- end }} {{- end }} {{- if eq .Values.kubeconfig.provider "gcp" }} fetch-gcp-kubeconfig.sh: | #!/bin/sh set -e echo "Fetching GCP GKE kubeconfigs..." # Retry configuration MAX_RETRIES=${MAX_RETRIES:-3} RETRY_DELAY=${RETRY_DELAY:-10} export KUBECONFIG=/kubeconfig/kubeconfig touch $KUBECONFIG # Function to retry commands retry_command() { local cmd="$1" local description="$2" local attempt=1 while [ $attempt -le $MAX_RETRIES ]; do echo "Attempt $attempt/$MAX_RETRIES: $description" if eval "$cmd"; then echo "✓ Success: $description" return 0 else if [ $attempt -eq $MAX_RETRIES ]; then echo "✗ Failed after $MAX_RETRIES attempts: $description" return 1 fi echo "⚠ Attempt $attempt failed, retrying in ${RETRY_DELAY}s..." sleep $RETRY_DELAY fi attempt=$((attempt + 1)) done } {{- range .Values.kubeconfig.gcp.clusters }} # Fetch cluster: {{ .name }} GCP_CMD="gcloud container clusters get-credentials {{ .clusterName | quote }}{{- if .zone }} --zone={{ .zone | quote }}{{- else if .region }} --region={{ .region | quote }}{{- end }}{{- if .project }} --project={{ .project | quote }}{{- end }} --kubeconfig $KUBECONFIG{{- range .extraArgs }} {{ . | quote }}{{- end }}" retry_command "$GCP_CMD" "Fetching GKE cluster {{ .name }}" {{- end }} {{- if .Values.kubeconfig.gcp.defaultContext }} echo "Setting default context: {{ .Values.kubeconfig.gcp.defaultContext }}" kubectl config use-context {{ .Values.kubeconfig.gcp.defaultContext | quote }} --kubeconfig=$KUBECONFIG {{- end }} echo "GCP kubeconfig setup complete" kubectl config get-contexts --kubeconfig=$KUBECONFIG {{- end }} {{- if eq .Values.kubeconfig.provider "url" }} fetch-url-kubeconfig.sh: | #!/bin/sh set -e echo "Downloading kubeconfigs from URLs..." # Retry configuration MAX_RETRIES=${MAX_RETRIES:-3} RETRY_DELAY=${RETRY_DELAY:-10} KUBECONFIG_FILES="" # Function to retry commands retry_command() { local cmd="$1" local description="$2" local attempt=1 while [ $attempt -le $MAX_RETRIES ]; do echo "Attempt $attempt/$MAX_RETRIES: $description" if eval "$cmd"; then echo "✓ Success: $description" return 0 else if [ $attempt -eq $MAX_RETRIES ]; then echo "✗ Failed after $MAX_RETRIES attempts: $description" return 1 fi echo "⚠ Attempt $attempt failed, retrying in ${RETRY_DELAY}s..." sleep $RETRY_DELAY fi attempt=$((attempt + 1)) done } {{- range $index, $config := .Values.kubeconfig.url.configs }} # Download: {{ $config.name }} CURL_CMD="curl -sS{{- range $config.extraArgs }} {{ . | quote }}{{- end }} -o /kubeconfig/{{ $config.name }}.yaml {{ $config.url | quote }}" retry_command "$CURL_CMD" "Downloading kubeconfig {{ $config.name }}" {{- if eq $index 0 }} KUBECONFIG_FILES="/kubeconfig/{{ $config.name }}.yaml" {{- else }} KUBECONFIG_FILES="$KUBECONFIG_FILES:/kubeconfig/{{ $config.name }}.yaml" {{- end }} {{- end }} echo "URL kubeconfig downloads complete" echo "KUBECONFIG will be set to: $KUBECONFIG_FILES" # Validate each kubeconfig file {{- range .Values.kubeconfig.url.configs }} echo "Validating {{ .name }}.yaml..." retry_command "kubectl config view --kubeconfig=/kubeconfig/{{ .name }}.yaml --minify" "Validating kubeconfig {{ .name }}" {{- end }} {{- end }} {{- if eq .Values.kubeconfig.provider "custom" }} fetch-custom-kubeconfig.sh: | #!/bin/sh set -e echo "Running custom kubeconfig command..." {{- if .Values.kubeconfig.custom.command }} {{ .Values.kubeconfig.custom.command }} \ {{- range .Values.kubeconfig.custom.args }} {{ . | quote }} \ {{- end }} {{- else }} echo "Error: No custom command specified" exit 1 {{- end }} echo "Custom kubeconfig setup complete" {{- end }} {{- end }} {{- if eq .Values.kubeconfig.provider "content" }} --- apiVersion: v1 kind: Secret metadata: name: {{ include "mcp-server-kubernetes.fullname" . }}-kubeconfig labels: {{- include "mcp-server-kubernetes.labels" . | nindent 4 }} {{- $commonAnnotations := include "mcp-server-kubernetes.annotations" . }} {{- if $commonAnnotations }} annotations: {{- $commonAnnotations | nindent 4 }} {{- end }} type: Opaque data: kubeconfig.yaml: {{ .Values.kubeconfig.content | b64enc }} {{- end }}

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Flux159/mcp-server-kubernetes'

If you have feedback or need assistance with the MCP directory API, please join our Discord server