Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Latest commit

 

History

History
102 lines (71 loc) · 3.67 KB

manage-backends.md

File metadata and controls

102 lines (71 loc) · 3.67 KB

Managing Backends

Add a new backend

To route traffic to a new backend, you must deploy a new Discoverer instance that discovers all Services and Endpoints and routes them appropriately.

Kubernetes

  1. Create a new Secret from the kubeconfig file for the cluster:

    BACKEND_NAME=new-k8s
    SECRET_NAME=${BACKEND_NAME}-discover-kubecfg
    kubectl -n gimbal-discovery create secret generic ${SECRET_NAME} \
        --from-file=config=./config \
        --from-literal=backend-name=${BACKEND_NAME}
  2. Update the deployment manifest. Set the deployment name to the name of the new backend, and set the Secret name to the name of the new Secret.

  3. Apply the updated manifest to the Gimbal cluster:

    kubectl -n gimbal-discovery apply -f new-k8s-discoverer.yaml
  4. Verify the Discoverer is running by checking the number of available replicas in the new deployment, and by checking the logs of the new pod.

OpenStack

  1. Ensure you have all the required credentials for the OpenStack cluster.

  2. Create a new Secret:

    BACKEND_NAME=new-openstack
    SECRET_NAME=${BACKEND_NAME}-discover-openstack
    kubectl -n gimbal-discovery create secret generic ${SECRET_NAME} \
        --from-file=certificate-authority-data=${CA_DATA_FILE} \
        --from-literal=backend-name=${BACKEND_NAME} \
        --from-literal=username=${OS_USERNAME} \
        --from-literal=password=${OS_PASSWORD} \
        --from-literal=auth-url=${OS_AUTH_URL} \
        --from-literal=tenant-name=${OS_TENANT_NAME}
  3. Update the deployment manifest. Set the deployment name to the name of the new backend, and update the secret name to the one created in the previous step.

  4. Apply the updated manifest to the Gimbal cluster:

    kubectl -n gimbal-discovery apply -f new-openstack-discoverer.yaml
  5. Verify the Discoverer is running by checking the number of available replicas in the new deployment, and by verifying the logs of the new pod.

Remove a backend

To remove a backend from the Gimbal cluster, the Discoverer and the discovered services must be deleted.

Delete the discoverer

  1. Find the Discoverer instance that's responsible for the backend:

    # Assuming a Kubernetes backend
    kubectl -n gimbal-discovery get deployments -l app=kubernetes-discoverer
  2. Delete the instance:

    kubectl -n gimbal-discovery delete deployment ${DISCOVERER_NAME}
  3. Delete the Secret that holds the credentials for the backend cluster:

    kubectl -n gimbal-discovery delete secret ${DISCOVERER_SECRET_NAME}

Delete Services and Endpoints

Warning: Performing this operation results in Gimbal not sending traffic to this backend.

  1. List the Services that belong to the cluster, and verify the list:

    kubectl --all-namespaces get svc -l gimbal.projectcontour.io/backend=${CLUSTER_NAME}
  2. List the namespaces with Services that were discovered:

    kubectl get svc --all-namespaces  -l gimbal.projectcontour.io/backend=${CLUSTER_NAME} -o jsonpath='{range .items[*]}{.metadata.namespace}{"\n"}{end}' | uniq
  3. Iterate over the namespaces and delete all Services and Endpoints:

    NAMESPACES=$(kubectl get svc --all-namespaces  -l gimbal.projectcontour.io/backend=${CLUSTER_NAME} -o jsonpath='{range .items[*]}{.metadata.namespace}{"\n"}{end}' | uniq)
    for ns in $NAMESPACES
    do
        kubectl -n $ns delete svc,endpoints -l gimbal.projectcontour.io/backend=${CLUSTER_NAME}
    done