Prepare Access to Kubernetes Cluster(s)
After you have created Kubernetes Cluster(s), this depends on your Kubernetes Provider but in many cases, should be by the following.
Access Kubernetes with KUBECONFIG File
Section titled “Access Kubernetes with KUBECONFIG File”In case you access Kubernetes with KUBECONFIG File, store them in working directory by the following
-
🟢 ManagementKubernetes ClusterTerminal window cp /CHANGEME/PATH/TO/management_cluster.yaml $HOME/opstella-installation/kubeconfigs/management_cluster.yaml -
🟦 Non-Production WorkloadKubernetes ClusterTerminal window cp /CHANGEME/PATH/TO/nonprod_cluster.yaml $HOME/opstella-installation/kubeconfigs/nonprod_cluster.yaml -
🟥 Production WorkloadKubernetes ClusterTerminal window cp /CHANGEME/PATH/TO/prod_cluster.yaml $HOME/opstella-installation/kubeconfigs/prod_cluster.yaml
Create Long-lived Access Token to Kubernetes
Section titled “Create Long-lived Access Token to Kubernetes”You will need to create a Service Account binded with cluster-admin Cluster Role to gain capability of Kubernetes Cluster and Workload Management.
You also need to obtain its Access Token, a long-lived access token one for authentication to cluster which will later be used for further installing subsystems and components and integration with Opstella.
You will creating a Service Account named: opstella-admin, binded with cluster-admin Cluster Role with Cluster Role Binding named opstella-admin-crb-clusteradmin
You will need to create them on ALL Kubernetes Cluster(s)
The uses are
- Configuring with Opstella Platform Integration with Kubernetes
- In case your Kubernetes Cluster will be accessed with CLI instructed in specific way from the Kubernetes Provider. You can optionally replace the accessing method with this.
-
Connect to the Kubernetes Cluster with CLI instructed by your provider (if needed)
-
Create Service Account
opstella-admininkube-systemNamespaceTerminal window kubectl create serviceaccount opstella-admin -n kube-system -
Create a Cluster Role Binding to
cluster-adminBuilt-in Cluster RoleTerminal window kubectl create clusterrolebinding opstella-admin-crb-clusteradmin --clusterrole=cluster-admin --serviceaccount=kube-system:opstella-admin -
Create Access Token
Terminal window kubectl apply -f - <<EOFapiVersion: v1kind: Secretmetadata:name: opstella-admin-tokennamespace: kube-systemannotations:kubernetes.io/service-account.name: opstella-admintype: kubernetes.io/service-account-tokenEOF -
Gather its Access Token and Server Certificate
Terminal window export OPSTELLA_ADMIN_CACERT=$(kubectl get secret opstella-admin-token -n kube-system --output=jsonpath='{.data.ca\.crt}')export OPSTELLA_ADMIN_TOKEN=$(kubectl get secret opstella-admin-token -n kube-system --output=jsonpath='{.data.token}' | base64 -d)
To replace the access token with long-lived access token, follow this extra step
-
Create Kubernetes Configuration File with Token from Service Account created
Please change Kubernetes API Endpoint and file name accordingly.
-
🟢 ManagementKubernetes Cluster:$HOME/opstella-installation/kubeconfigs/management_cluster.yaml -
🟦 Non-Production WorkloadKubernetes Cluster:$HOME/opstella-installation/kubeconfigs/nonprod_cluster.yaml -
🟥 Production WorkloadKubernetes Cluster:$HOME/opstella-installation/kubeconfigs/prod_cluster.yaml
Terminal window # If your Kubernetes doesn't need to specify port, you may need to remove it.export KUBERNETES_API_ENDPOINT="https://CHANGEME-TO-K8S-API-ENDPOINT:6443"cat << EOF > /CHANGEME/PATH/TO/your_cluster.yamlapiVersion: v1clusters:- cluster:certificate-authority-data: ${OPSTELLA_ADMIN_CACERT}server: ${KUBERNETES_API_ENDPOINT}name: CHANGEME-YOUR-CLUSTER-NAMEcontexts:- context:cluster: CHANGEME-YOUR-CLUSTER-NAMEuser: defaultname: CHANGEME-YOUR-CLUSTER-NAMEcurrent-context: CHANGEME-YOUR-CLUSTER-NAMEkind: Configpreferences: {}users:- name: defaultuser:token: ${OPSTELLA_ADMIN_TOKEN}EOF -
Store in Working Directory
Section titled “Store in Working Directory”Put your KUBECONFIG files into the following directory.
-
🟢 ManagementKubernetes Cluster:$HOME/opstella-installation/kubeconfigs/management_cluster.yaml -
🟦 Non-Production WorkloadKubernetes Cluster:$HOME/opstella-installation/kubeconfigs/nonprod_cluster.yaml -
🟥 Production WorkloadKubernetes Cluster:$HOME/opstella-installation/kubeconfigs/prod_cluster.yaml
Finished?
Use the below navigation to proceed