17

Gitlab MicroK8s CI/CD Integration

 2 years ago
source link: https://gist.github.com/hardyscc/b64d3c0e1ab20004a3e9431e74fd88cd
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Gitlab MicroK8s CI/CD Integration

Install microk8s

sudo snap install microk8s --classic
sudo microk8s status --wait-ready

Install plugins

sudo microk8s enable dns ingress rbac storage

Switch to use kubectl

sudo snap install kubectl helm --classic
mkdir ~/.kube
sudo microk8s config > ~/.kube/config
chmod 600 ~/.kube/config

Add your domain as follow

sudo sed -i '/DNS.5/a \
DNS.6 = api.yourdomain.com' /var/snap/microk8s/current/certs/csr.conf.template

Config DNS

  • A-Record : yourdomain.com > <YOUR_IP_ADDRESS>
  • Alias (CNAME) : api.yourdomain.com > yourdomain.com
  • Alias (CNAME) : *.apps.yourdomain.com > yourdomain.com

Config Port Forward

  • 16443

Gitlab setup

  • Kubernetes cluster name : microk8s-cluster
  • API URL : https://api.yourdomain.com:16443
  • Base Domain : apps.yourdomain.com

Get the CA Certificate

kubectl get secret $(kubectl get secret | grep default-token | awk '{print $1}') -o jsonpath="{['data']['ca\.crt']}" | base64 --decode

Get the Service Token

kubectl -n kube-system create serviceaccount gitlab
kubectl create clusterrolebinding gitlab-admin --clusterrole=cluster-admin --serviceaccount=kube-system:gitlab
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep gitlab | awk '{print $1}')

Finally install Gitlab Runner and Cert-Manager under Applications tab page


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK