Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCP Connector support for Spaces #395

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

tnthornton
Copy link
Member

@tnthornton tnthornton commented Oct 12, 2023

Description of your changes

We'd like to enable operators to install the mcp-connector into App Clusters pointing to a Space control plane. In order to accomplish that, we needed to slightly extend what the current up ctp connector install command is doing and allow passing in:

--control-plane-secret={secret name}

so that an operator can supply the control plane secret.

In addition, we wanted to make it easier to uninstall the mcp-connector. To accomplish this a new subcommand up ctp connector uninstall was introduced.

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

  1. Verify commands exist
./_output/bin/darwin_arm64/up ctp connector --help
Usage: up controlplane (ctp) connector <command>

Connect an App Cluster to a managed control plane.

Flags:
  -h, --help                         Show context-sensitive help.
      --format="default"             Format for get/list commands. Can be: json, yaml, default
  -v, --version                      Print version and exit.
  -q, --quiet                        Suppress all output.
      --pretty                       Pretty print output.

      --domain=https://upbound.io    Root Upbound domain ($UP_DOMAIN).
      --profile=STRING               Profile used to execute command ($UP_PROFILE).
  -a, --account=STRING               Account used to execute command ($UP_ACCOUNT).
      --insecure-skip-tls-verify     [INSECURE] Skip verifying TLS certificates ($UP_INSECURE_SKIP_TLS_VERIFY).
  -d, --debug=INT                    [INSECURE] Run with debug logging. Repeat to increase verbosity. Output
                                     might contain confidential data like tokens ($UP_DEBUG).

Commands:
  controlplane (ctp) connector install      Install mcp-connector into an App Cluster.
  controlplane (ctp) connector uninstall    Uninstall mcp-connector from an App Cluster.
  1. Installing mcp-connector
./_output/bin/darwin_arm64/up ctp connector install ctp1 default --control-plane-secret=test

kubectl -n kube-system get pods -o custom-columns="POD_NAME":".metadata.name"
POD_NAME
coredns-565d847f94-5tld8
coredns-565d847f94-92fc9
etcd-kind-control-plane
kindnet-fwmqk
kube-apiserver-kind-control-plane
kube-controller-manager-kind-control-plane
kube-proxy-jztks
kube-scheduler-kind-control-plane
mcp-connector-b88847fb7-mljm8
  1. Check the volume has 'test' as the secretName:
kubectl -n kube-system get deploy mcp-connector -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
    meta.helm.sh/release-name: mcp-connector
    meta.helm.sh/release-namespace: kube-system
  creationTimestamp: "2023-10-12T17:16:15Z"
  generation: 1
  labels:
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: mcp-connector
  name: mcp-connector
  namespace: kube-system
  resourceVersion: "4063"
  uid: 476f5c46-df37-4a30-af8b-d760e0d48f29
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: mcp-connector
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app.kubernetes.io/name: mcp-connector
    spec:
      containers:
      - args:
        - serve
        - --mcp-kubeconfig=/etc/mcp/kubeconfig
        - --mcp-namespace=default
        - --debug
        image: upbound/mcp-connector:v0.3.4
        imagePullPolicy: IfNotPresent
        name: apiserver
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/mcp
          name: mcp-kubeconfig
          readOnly: true
      - args:
        - bind
        - --mcp-kubeconfig=/etc/mcp/kubeconfig
        - --service-name=mcp-connector
        - --service-namespace=kube-system
        - --service-port=443
        - --debug
        image: upbound/mcp-connector:v0.3.4
        imagePullPolicy: IfNotPresent
        name: binder
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/mcp
          name: mcp-kubeconfig
          readOnly: true
      dnsPolicy: ClusterFirst
      initContainers:
      - args:
        - init
        - default
        - --mcp-kubeconfig=/etc/mcp/kubeconfig
        - --debug
        image: upbound/mcp-connector:v0.3.4
        imagePullPolicy: IfNotPresent
        name: init
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/mcp
          name: mcp-kubeconfig
          readOnly: true
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: mcp-connector
      serviceAccountName: mcp-connector
      terminationGracePeriodSeconds: 30
      volumes:
      - name: mcp-kubeconfig
        secret:
          defaultMode: 420
          secretName: test                                                 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
status:
  conditions:
  - lastTransitionTime: "2023-10-12T17:16:15Z"
    lastUpdateTime: "2023-10-12T17:16:15Z"
    message: Deployment does not have minimum availability.
    reason: MinimumReplicasUnavailable
    status: "False"
    type: Available
  - lastTransitionTime: "2023-10-12T17:16:15Z"
    lastUpdateTime: "2023-10-12T17:16:15Z"
    message: ReplicaSet "mcp-connector-b88847fb7" is progressing.
    reason: ReplicaSetUpdated
    status: "True"
    type: Progressing
  observedGeneration: 1
  replicas: 1
  unavailableReplicas: 1
  updatedReplicas: 1
  1. Uninstall mcp-connector
./_output/bin/darwin_arm64/up ctp connector uninstall default
MCP Connector uninstalled

kubectl -n kube-system get pods -o custom-columns="POD_NAME":".metadata.name"
POD_NAME
coredns-565d847f94-5tld8
coredns-565d847f94-92fc9
etcd-kind-control-plane
kindnet-fwmqk
kube-apiserver-kind-control-plane
kube-controller-manager-kind-control-plane
kube-proxy-jztks
kube-scheduler-kind-control-plane

…e profile

Signed-off-by: Taylor Thornton <thornton.tn@gmail.com>
Signed-off-by: Taylor Thornton <thornton.tn@gmail.com>
@tnthornton tnthornton requested a review from a team October 12, 2023 01:19
Copy link
Contributor

@AlainRoy AlainRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤘

@@ -108,31 +108,50 @@ type installCmd struct {
ClusterName string `help:"Name of the cluster connecting to the control plane. If not provided, the namespace argument value will be used."`
Kubeconfig string `type:"existingfile" help:"Override the default kubeconfig path."`
InstallationNamespace string `short:"n" env:"MCP_CONNECTOR_NAMESPACE" default:"kube-system" help:"Kubernetes namespace for MCP Connector. Default is kube-system."`
ControlPlaneSecret string `help:"Name of the secret that contains the kubeconfig for a control plane."`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not quite obvious how to use this -- we'll have to make sure it gets into the documentation. @cwilhit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, will do

@tnthornton tnthornton changed the title MCP Connector support to for Spaces MCP Connector support for Spaces Oct 12, 2023
Signed-off-by: Taylor Thornton <thornton.tn@gmail.com>
@tnthornton tnthornton marked this pull request as ready for review October 12, 2023 17:31
@tnthornton tnthornton merged commit cb488c1 into upbound:main Oct 12, 2023
6 checks passed
@tnthornton tnthornton deleted the up-ctp-connector-install branch October 12, 2023 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants