Skip to content
Search

GitLab:Kubernetes

lastmod 2025-02-14created 2022-12-094 edits

How to integrate k8s with GitLab, installing gitlab on k8s, etc. ...

Mainly intended for use in CI/CD.

Installing gitlab on k8s

Building a CI/CD environment using k8s with gitlab

Fill in the input fields as follows

  • Kubernetes cluster name: enter any name
  • Environment scope: *
  • API URL: https://{Masternode ip}:6443 (HTTPS is correct!!)
  • CA Certificate: can be checked on the master node with the following command.

    *

kubectl config view --raw \ -o=jsonpath='{.clusters[0].cluster.certificate-authority-data}' \ | base64 --decode

</syntaxhighlight>

  • Service Token: before getting the service token, you need to create a service account for GitLab to use.
    • A service token scoped to kube-system with cluster-admin privileges. More information

    *

  1. gitlab-admin.yaml

apiVersion: v1 kind: ServiceAccount metadata:

name: gitlab-admin
namespace: kube-system

--- apiVersion: rbac.authorization.k8s.io/v1 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

</syntaxhighlight>

    • After saving, run it as follows:

$ kubectl apply -f gitlab-admin.yaml serviceaccount/gitlab-admin unchanged clusterrolebinding.rbac.authorization.k8s.io/gitlab-admin created

</syntaxhighlight>

Problems

The token cannot be obtained.

Troubleshooting

no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"

If you get the following error when running kubectl apply -f gitlab-admin.yaml:

serviceaccount/gitlab-admin created
error: resource mapping not found for name: "gitlab-admin" namespace: "" from "gitlab-admin.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
ensure CRDs are installed first

If you set the apiVersion of ClusterRoleBinding to rbac.authorization.k8s.io/v1beta, change it to rbac.authorization.k8s.io/v1 for it to work properly.

See also

author Zer0 sitemap