I am searching for a way to use kubectl in gitlab.
So far I have the following script:
deploy_to_dev:
stage: deploy
image: docker:dind
environment:
name: dev
script:
- mkdir -p $HOME/.kube
- echo $KUBE_CONFIG | base64 -d > $HOME/.kube/config
- kubectl config view
only:
- develop
But it says that gitlab does not know kubectl. So can you point me in the right direction.
You can connect your Kubernetes cluster with GitLab to deploy, manage, and monitor your cloud-native solutions. To connect a Kubernetes cluster to GitLab, you must first install an agent in your cluster. The agent runs in the cluster, and you can use it to: Communicate with a cluster, which is behind a firewall or NAT.
This Kubernetes-native architecture allows your CI/CD pipeline to be portable and function across multiple cloud providers and locations. The declarative nature of Tekton and Kubernetes allows you to standardize, collaborate, and share your workflows across teams.
Use image google/cloud-sdk
which has a preinstalled installation of gcloud and kubectl.
build:
stage: build
image: google/cloud-sdk
services:
- docker:dind
script:
# Make gcloud available
- source /root/.bashrc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With