Skip to content

Instantly share code, notes, and snippets.

@nirbhabbarat
Created August 15, 2020 10:47
Show Gist options
  • Save nirbhabbarat/b411af10bd140bcfb5afb68d9431164d to your computer and use it in GitHub Desktop.
Save nirbhabbarat/b411af10bd140bcfb5afb68d9431164d to your computer and use it in GitHub Desktop.
Integrate gitlab installed in minikube and kubenetes running in same minikube

Enable outbound local network in gitlab admin

Goto: Admin Area -> Settings -> Network -> Outbound Requests Enable Allow requests to the local network from web hooks and services and Save

Example: https://gitlab.172.17.0.3.nip.io/admin/application_settings/network

Read More: https://docs.gitlab.com/ee/security/webhooks.html

Must Read: https://gitlab.172.17.0.3.nip.io/help/user/project/clusters/add_remove_clusters.md#add-existing-cluster

Get API URL

kubectl cluster-info | grep 'Kubernetes master' | awk '/http/ {print $NF}'

Get CA Certificate

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

Create Service Account

apiVersion: v1
kind: ServiceAccount
metadata:
  name: gitlab-admin
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: gitlab-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: gitlab-admin
    namespace: kube-system

Apply via kubectl

kubectl apply -f gitlab-admin-service-account.yaml

Get Admin Service token

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep gitlab-admin | awk '{print $1}')

Note: Not recommended for production

minikube ssh
grep client-certificate-data /etc/kubernetes/admin.conf

note: its in base64, so decode it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment