Add EKS Account
At a high level, Spinnaker operates in the following way when deploying to Kubernetes:
- Spinnaker is configured with one or more “Cloud Provider” Kubernetes accounts (which you can think of as deployment targets)
- For each Kubernetes account, Spinnaker is provided a kubeconfig to connect to that Kubernetes cluster
- The kubeconfig should have the following contents:
- A Kubernetes kubeconfig cluster
- A Kubernetes kubeconfig user
- A Kubernetes kubeconfig context
- Metadata such as which context to use by default
- Each Kubernetes account is configured in the SpinnakerService manifest under spec.spinnakerConfig.config.providers.kubernetes.accounts key. Each entity has these (and other) fields:
- name: A Spinnaker-internal name
- kubeconfigFile: A file path referencing the contents of the kubeconfig file for connecting to the target cluster.
- onlySpinnakerManaged: When true, Spinnaker only caches and displays applications that have been created by Spinnaker.
- namespaces: An array of namespaces that Spinnaker will be allowed to deploy to. If this is left blank, Spinnaker will be allowed to deploy to all namespaces
- omitNamespaces: If namespaces is left blank, you can blacklist specific namespaces to indicate to Spinnaker that it should not deploy to those namespaces
- If the kubeconfig is properly referenced and available, Operator will take care of the following:
- Creating a Kubernetes secret containing your kubeconfig in the namespace where Spinnaker lives
- Dynamically generating a clouddriver.yml file that properly references the kubeconfig from where it is mounted within the Clouddriver container
- Creating/Updating the Kubernetes Deployment (spin-clouddriver) which runs Clouddriver so that it is aware of the secret and properly mounts it in the Clouddriver pod
Now, lets add a Kubernetes/EKS Account Deployment Target in Spinnaker.
This tool helps to create the ServiceAccount, ClusterRoleBinding, kubeconfig for the service account for the EKS/Kubernetes account
cd ~/environment
git clone https://github.com/armory/spinnaker-tools.git
cd spinnaker-tools
go mod download all
go build
Setup environment variables
export CONTEXT=$(kubectl config current-context)
export SOURCE_KUBECONFIG=${HOME}/.kube/config
export SPINNAKER_NAMESPACE="spinnaker"
export SPINNAKER_SERVICE_ACCOUNT_NAME="spinnaker-ws-sa"
export DEST_KUBECONFIG=${HOME}/Kubeconfig-ws-sa
echo $CONTEXT
echo $SOURCE_KUBECONFIG
echo $SPINNAKER_NAMESPACE
echo $SPINNAKER_SERVICE_ACCOUNT_NAME
echo $DEST_KUBECONFIG
If you do not see output from the above command for all the above Environment Variables, do not proceed to next step
Create the service account
Create the kubernetes service account with namespace-specific permissions
./spinnaker-tools create-service-account --kubeconfig ${SOURCE_KUBECONFIG} --context ${CONTEXT} --output ${DEST_KUBECONFIG} --namespace ${SPINNAKER_NAMESPACE} --service-account-name ${SPINNAKER_SERVICE_ACCOUNT_NAME}
Open the SpinnakerService
manifest located under deploy/spinnaker/basic/spinnakerservice.yml
, then add the below to the section spec.spinnakerConfig.config
.
Open the SpinnakerService
manifest located under deploy/spinnaker/basic/spinnakerservice.yml
, then add the below section under spec.spinnakerConfig
. Replace the <FILE CONTENTS HERE>
in below section with kubeconfig file content created from previous step from the location ${HOME}/Kubeconfig-ws-sa.
Congratulations! You are done with the Spinnaker configuration for all the Spinnaker services! Lets install Spinnaker now.