Initial configuration of Kubernetes/Kyma cluster
Configuration of Kyma cluster and preparation of the Github repository for CI/CD via Github Actions.
Prerequisites
- Kyma cluster on SAP BTP Trial
- Kubernetes CLI tool
kubectlwith a connection to your Kyma cluster - Account on github.com
Prepare cluster
- Create namespace
btptour
kubectl create namespace btptour
Hint: You can use the Terminal window of the Business Application Studio to run all commands and scripts listed on a Windows machine.
Hint
You can use the Terminal window of the Business Application Studio to run all commands and scripts listed on a Windows machine.
Enable Kubernetes/Kyma to pull container images from ghcr.io
-
Create new Personal Access Token (PAT) in Github (Profile > Settings > Developer settings > Personal access tokens) with scope
read:packages. -
Create secret for pulling images from Github container registry
kubectl -n btptour create secret docker-registry regcred \
--docker-server=https://ghcr.io \
--docker-username=<github user> \
--docker-password=<github personal access token>
Enable Github actions to access the cluster
- Create service account
kubectl apply -f serviceaccount.yml -n btptour
-
Assemble a cluster access configuration for the service account
The access configuration for the cluster can be created with the create_kubeconfig.sh shell script and stored in the file kubeconfig.yml as follows:
bash create_kubeconfig.sh > kubeconfig.yml
-
Encode the cluster access configuration in Base64
For use within Github Actions the configuration text file needs to be converted to a text file in Base64 encoding:
cat kubeconfig.yml | base64 > secret.txt
-
Add the config securely to the Github repository
Create a new secret with the name
BTP_TRIAL_KUBECONFIGin the Github repository (Settings > Secrets > Actions) with the contents of the secret.txt file.