GitlabとRedmineをKubernetesで構築する

Kubernetesの勉強のために、昔 docker-composeで構築したGitlabとRedmine
今度はKubernetesで構築してみました。
具体的にはIngressを使ってみたかった感じです。

今回は1台のESXiサーバー上にシングルノードで構築したKubernetesを利用しました。

ubuntu@k8s:~$ kubectl get nodes
NAME   STATUS   ROLES                  AGE   VERSION
k8s    Ready    control-plane,master   29h   v1.20.15

OS構築準備

cloud-initを作った時のコマンドを自分用にメモ。
macOSでgenisoimageが使えないようなのでコンテナでisoを作ります。

% cat Dockerfile 
FROM ubuntu:focal
RUN apt-get update && apt install -y qemu qemu-utils genisoimage
% docker build -t genisoimage:v1 .

コンテナにファイルをマウントしてgenisoimageコマンドを実行します。

% cat meta-data 
instance-id: k8s
local-hostname: k8s
% cat user-data 
#cloud-config
password: P@ssw0rd
chpasswd: {expire: False}
ssh_pwauth: True
% docker run -it --rm --name genisoimage -v /Users/tsuchinoko/work/cloudinit/volume:/volume genisoimage:v1 genisoimage -output /volume/cloud-init.iso -volid cidata -joliet -rock /volume/user-data /volume/meta-data

Ubuntu 20.04.4 LTSを使います。
公式から提供されているcloud imageをvmdkに変換します。

qemu-img convert -O vmdk focal-server-cloudimg-amd64.img focal-server-cloudimg-amd64.vmdk

cloud-initの使い方はこちら

NFSサーバー

今回PVにnfsを使うのでk8sノードにnfs-commonをインストールします。

ubuntu@k8s:~$ apt list --installed | grep nfs-common
nfs-common/focal-updates,now 1:1.3.4-2.5ubuntu3.4 amd64 [installed]

nfsサーバーは別途構築してます。
PVに指定するパスのディレクトリは作成しておいてください。

MetalLB

外部接続にL2設定のMetalLBを利用します。
設定方法はこちら を参考にしてください。
以下の設定にしました。

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  namespace: metallb-system
  name: first-pool
spec:
  addresses:
  - 192.168.10.220-192.168.10.230
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: example
  namespace: metallb-system
spec:
  ipAddressPools:
  - first-pool

Ingress

こちら を参考にインストールしました。
NGINX ingress経由でgitlabにssh通信したいのでtcp-services-configmapのフラグをつけます。
ドキュメントはこちら です。

$ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
$ helm repo update
$ helm install my-release ingress-nginx/ingress-nginx -n ingress-system --set tcp.10022="default/gitlab:10022"

ConfigMap作らなくても引数で指定するこの方法が楽ですね。
必要な設定も入ってました。

$ kubectl get cm my-release-ingress-nginx-tcp -n ingress-system -o jsonpath='{.data}' 
{"10022":"default/gitlab:10022"}
$ kubectl describe pod -n ingress-system | grep tcp-services-configmap
      --tcp-services-configmap=$(POD_NAMESPACE)/my-release-ingress-nginx-tcp

Secret

NGINX Ingressでhttpsを受けるようにします。
まずLet’s Encrypt証明書を発行します。 詳しくはこちら で。

発行した証明書でSecretを作成します。
ディレクトリは自分のドメインに書き換えてください。
これはNGINXとGitLabとRegistryで使います。

$ sudo kubectl create secret tls example-tls --key /etc/letsencrypt/live/example.tsuchinokometal.com/privkey.pem --cert /etc/letsencrypt/live/example.tsuchinokometal.com/fullchain.pem --dry-run=client -o yaml > example-tls.yaml
$ kubectl apply -f example-tls.yaml

自動更新はされないのでご注意ください。

Volume

sameersbn/gitlab を使います。
GitLab用のVolumeをデプロイします。

apiVersion: v1
kind: PersistentVolume
metadata:
  name: gitlab-postgresql-pv
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  claimRef:
    namespace: default
    name: gitlab-postgresql-pvc
  nfs:
    path: /nfs/gitlab/postgresql
    server: 192.168.10.205 
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gitlab-data-pv
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  claimRef:
    namespace: default
    name: gitlab-data-pvc
  nfs:
    path: /nfs/gitlab/gitlab
    server: 192.168.10.205
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-postgresql-pvc
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-data-pvc
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi

Redmine用のVolumeをデプロイします。
sameersbn/redmine を使います。

apiVersion: v1
kind: PersistentVolume
metadata:
  name: redmine-data-pv
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  claimRef:
    namespace: default
    name: redmine-data-pvc
  nfs:
    path: /nfs/redmine/redmine
    server: 192.168.10.205 
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redmine-logs-pv
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  claimRef:
    namespace: default
    name: redmine-logs-pvc
  nfs:
    path: /nfs/redmine/logs
    server: 192.168.10.205
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redmine-postgresql-pv
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  claimRef:
    namespace: default
    name: redmine-postgresql-pvc
  nfs:
    path: /nfs/redmine/postgresql
    server: 192.168.10.205
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redmine-data-pvc
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redmine-logs-pvc
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redmine-postgresql-pvc
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi

Deployment,Service

GitLab用のPostgreSQLをデプロイします。

apiVersion: v1
kind: Service
metadata:
  name: gitlab-postgresql
spec:
  selector:
    app: gitlab-postgresql
  ports:
  - protocol: TCP
    port: 5432
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab-postgresql
  labels:
    app: gitlab-postgresql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitlab-postgresql
  template:
    metadata:
      labels:
        app: gitlab-postgresql
    spec:
      containers:
      - name: postgresql
        image: sameersbn/postgresql:12-20200524
        ports:
        - containerPort: 5432
        env:
        - name: DB_USER
          value: "gitlab"
        - name: DB_PASS
          value: "password"
        - name: DB_NAME
          value: "gitlabhq_production"
        - name: DB_EXTENSION
          value: "pg_trgm,btree_gist"
        volumeMounts:
        - mountPath: "/var/lib/postgresql"
          name: data
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: gitlab-postgresql-pvc

GitLab用のRedisをデプロイします。

apiVersion: v1
kind: Service
metadata:
  name: gitlab-redis
spec:
  selector:
    app: gitlab-redis
  ports:
  - protocol: TCP
    port: 6379
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab-redis
  labels:
    app: gitlab-redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitlab-redis
  template:
    metadata:
      labels:
        app: gitlab-redis
    spec:
      containers:
      - name: redis
        image: redis:6.2.6
        ports:
        - containerPort: 6379
        volumeMounts:
        - mountPath: "/var/lib/redis"
          name: data
      volumes:
      - name: data
        emptyDir: {}

GitLabをデプロイします。
ポイントはGITLAB_RELATIVE_URL_ROOTでサブディレクトリにしている点です。

apiVersion: v1
kind: Service
metadata:
  name: gitlab 
spec:
  selector:
    app: gitlab
  ports:
  - name: http
    protocol: TCP
    port: 10080
    targetPort: 80
  - name: ssh
    protocol: TCP
    port: 10022
    targetPort: 22
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab
  labels:
    app: gitlab
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitlab
  template:
    metadata:
      labels:
        app: gitlab
    spec:
      containers:
      - name: gitlab
        image: sameersbn/gitlab:15.1.2
        ports:
        - name: http
          containerPort: 80
          protocol: TCP
        - name: ssh
          containerPort: 22
          protocol: TCP
        env:
        - name: TZ
          value: Asia/Tokyo
        - name: GITLAB_TIMEZONE
          value: Tokyo

        - name: GITLAB_SECRETS_DB_KEY_BASE
          value: long-and-random-alpha-numeric-string
        - name: GITLAB_SECRETS_SECRET_KEY_BASE
          value: long-and-random-alpha-numeric-string
        - name: GITLAB_SECRETS_OTP_KEY_BASE
          value: long-and-random-alpha-numeric-string

        - name: GITLAB_ROOT_PASSWORD
          value: "P@ssw0rd"

        - name: GITLAB_HOST
          value: example.tsuchinokometal.com
        - name: GITLAB_PORT
          value: "10080"
        - name: GITLAB_SSH_PORT
          value: "10022"
        - name: GITLAB_RELATIVE_URL_ROOT
          value: /gitlab
        - name: GITLAB_HTTPS
          value: "true"

        - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS
          value: "true"
        - name: GITLAB_NOTIFY_PUSHER
          value: "false"

        - name: GITLAB_BACKUP_SCHEDULE
          value: daily
        - name: GITLAB_BACKUP_TIME
          value: 01:00

        - name: DB_TYPE
          value: postgres
        - name: DB_HOST
          value: gitlab-postgresql
        - name: DB_PORT
          value: "5432"
        - name: DB_USER
          value: gitlab
        - name: DB_PASS
          value: password
        - name: DB_NAME
          value: gitlabhq_production 

        - name: REDIS_HOST
          value: gitlab-redis
        - name: REDIS_PORT
          value: "6379"

        - name: SMTP_ENABLED
          value: "false"
        - name: SMTP_DOMAIN
          value: www.example.com
        - name: SMTP_HOST
          value: smtp.gmail.com
        - name: SMTP_PORT
          value: "587"
        - name: SMTP_USER
          value: mailer@example.com
        - name: SMTP_PASS
          value: password
        - name: SMTP_STARTTLS
          value: "true"
        - name: SMTP_AUTHENTICATION
          value: login

        - name: IMAP_ENABLED
          value: "false"
        - name: IMAP_HOST
          value: imap.gmail.com
        - name: IMAP_PORT
          value: "993"
        - name: IMAP_USER
          value: mailer@example.com
        - name: IMAP_PASS
          value: password
        - name: IMAP_SSL
          value: "true"
        - name: IMAP_STARTTLS
          value: "false"

        - name: GITLAB_REGISTRY_ENABLED
          value: "true"
        - name: GITLAB_REGISTRY_HOST
          value: example.tsuchinokometal.com 
        - name: GITLAB_REGISTRY_PORT
          value: "443"
        - name: GITLAB_REGISTRY_API_URL
          value: http://registry:5000
        - name: GITLAB_REGISTRY_KEY_PATH
          value: /certs/tls.key

        volumeMounts:
        - mountPath: "/home/git/data"
          name: data
        - name: secret-volume
          mountPath: /certs 
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: gitlab-data-pvc
      - name: secret-volume
        secret:
          secretName: example-tls
          items:
          - key: tls.crt
            path: tls.crt
            mode: 0644
          - key: tls.key
            path: tls.key
            mode: 0644

Redmine用のPostgreSQLをデプロイします。

apiVersion: v1
kind: Service
metadata:
  name: redmine-postgresql
spec:
  selector:
    app: redmine-postgresql
  ports:
  - protocol: TCP
    port: 5432
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redmine-postgresql
  labels:
    app: redmine-postgresql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redmine-postgresql
  template:
    metadata:
      labels:
        app: redmine-postgresql
    spec:
      containers:
      - name: postgresql
        image: sameersbn/postgresql:9.6-4
        ports:
        - containerPort: 5432
        env:
        - name: DB_USER
          value: "redmine"
        - name: DB_PASS
          value: "password"
        - name: DB_NAME
          value: "redmine_production"
        volumeMounts:
        - mountPath: "/var/lib/postgresql"
          name: redmine-data
      volumes:
      - name: redmine-data
        persistentVolumeClaim:
          claimName: redmine-postgresql-pvc

Redmineをデプロイします。
GitLabのデータのあるPVもマウントしています。
こちらもサブディレクトリにしています。

apiVersion: v1
kind: Service
metadata:
  name: redmine
spec:
  selector:
    app: redmine
  ports:
  - protocol: TCP
    port: 10083
    targetPort: 80 
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redmine
  labels:
    app: redmine
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redmine
  template:
    metadata:
      labels:
        app: redmine
    spec:
      containers:
      - name: redmine
        image: sameersbn/redmine:5.0.2
        ports:
        - containerPort: 80
        env:
        - name: TZ
          value: "Asia/Tokyo"
        - name: DB_ADAPTER
          value: "postgresql"
        - name: DB_HOST
          value: "redmine-postgresql"
        - name: DB_USER
          value: "redmine"
        - name: DB_PASS
          value: "password"
        - name: DB_NAME
          value: "redmine_production"
        - name: DB_SSL_MODE
          value: "prefer"
        - name: REDMINE_PORT
          value: "10083"
        - name: REDMINE_HTTPS
          value: "false"
        - name: REDMINE_RELATIVE_URL_ROOT
          value: "/redmine"
        - name: REDMINE_SECRET_TOKEN
          value: "secret"
        - name: REDMINE_SUDO_MODE_ENABLED
          value: "false"
        - name: REDMINE_SUDO_MODE_TIMEOUT
          value: "15"
        - name: REDMINE_CONCURRENT_UPLOADS
          value: "2"
        - name: REDMINE_BACKUP_SCHEDULE
          value: ""
        - name: REDMINE_BACKUP_EXPIRY
          value: ""
        - name: REDMINE_BACKUP_TIME
          value: ""
        volumeMounts:
        - mountPath: "/home/redmine/data"
          name: redmine-data
        - mountPath: "/home/git/data"
          name: gitlab-data
        - mountPath: "/var/log/redmine"
          name: redmine-logs
      volumes:
      - name: redmine-data
        persistentVolumeClaim:
          claimName: redmine-data-pvc
      - name: gitlab-data
        persistentVolumeClaim:
          claimName: gitlab-data-pvc
      - name: redmine-logs
        persistentVolumeClaim:
          claimName: redmine-logs-pvc

Registry

GitLabとRegistryの連携部分を作っておきます。

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: registry-pv
  labels:
    name: registry-pv
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: /nfs/registry
    server: 192.168.10.205
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: registry-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  selector:
    matchLabels:
      name: registry-pv
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: registry
  name: registry
spec:
  containers:
  - image: registry:2
    name: registry
    ports:
    - name: registry
      containerPort: 5000
    env:
    - name: REGISTRY_LOG_LEVEL
      value: info
    - name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
      value: /registry
    - name: REGISTRY_AUTH_TOKEN_REALM
      value: https://example.tsuchinokometal.com/gitlab/jwt/auth
    - name: REGISTRY_AUTH_TOKEN_SERVICE
      value: container_registry
    - name: REGISTRY_AUTH_TOKEN_ISSUER
      value: gitlab-issuer
    - name: REGISTRY_AUTH_TOKEN_ROOTCERTBUNDLE
      value: /certs/tls.crt
    - name: REGISTRY_STORAGE_DELETE_ENABLED
      value: "true"
    volumeMounts:
    - name: registry-data
      mountPath: /registry
    - name: secret-volume
      mountPath: /certs
  volumes:
  - name: registry-data
    persistentVolumeClaim:
      claimName: registry-pvc
  - name: secret-volume
    secret:
      secretName: example-tls
      items:
      - key: tls.crt
        path: tls.crt
        mode: 0644
      - key: tls.key
        path: tls.key
        mode: 0644
---
apiVersion: v1
kind: Service
metadata:
  labels:
    run: registry
  name: registry
spec:
  ports:
  - port: 5000
    protocol: TCP
    targetPort: 5000
  selector:
    run: registry
  type: ClusterIP

Ingress

NGINX Ingressの設定は以下としました。
コンテナイメージをpushするためにproxy-body-sizeを設定しています。
Let’s Encrypt証明書で作成したSecretをここで指定してhttps通信を行えるようにします。

apiVersion: networking.k8s.io/v1 
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: 1000m
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  ingressClassName: "nginx"
  tls:
  - hosts:
    - example.tsuchinokometal.com
    secretName: example-tls
  rules:
  - host: example.tsuchinokometal.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: registry 
            port:
              number: 5000
      - path: /gitlab
        pathType: Prefix
        backend:
          service:
            name: gitlab
            port:
              number: 10080
      - path: /redmine
        pathType: Prefix
        backend:
          service:
            name: redmine
            port:
              number: 10083

こんな感じになると思います。

$ kubectl get po,pv,pvc,svc,ingress -A
NAMESPACE        NAME                                                       READY   STATUS    RESTARTS   AGE
default          pod/gitlab-5b778ff7c6-vvm6s                                1/1     Running   0          34m
default          pod/gitlab-postgresql-549f56b57d-sxk4d                     1/1     Running   0          2d1h
default          pod/gitlab-redis-fbf988b57-ft992                           1/1     Running   0          2d1h
default          pod/redmine-6687598986-hhm2s                               1/1     Running   2          2d1h
default          pod/redmine-postgresql-6dcdd9b7f-wc246                     1/1     Running   0          2d1h
default          pod/registry                                               1/1     Running   0          2d1h
ingress-system   pod/my-release-ingress-nginx-controller-6779d9f55f-tr2md   1/1     Running   0          42m
kube-flannel     pod/kube-flannel-ds-jrmdm                                  1/1     Running   0          2d1h
kube-system      pod/coredns-74ff55c5b-6ssfp                                1/1     Running   0          2d1h
kube-system      pod/coredns-74ff55c5b-v5jns                                1/1     Running   0          2d1h
kube-system      pod/etcd-k8s                                               1/1     Running   0          2d1h
kube-system      pod/kube-apiserver-k8s                                     1/1     Running   0          2d1h
kube-system      pod/kube-controller-manager-k8s                            1/1     Running   1          2d1h
kube-system      pod/kube-proxy-vz7jh                                       1/1     Running   0          2d1h
kube-system      pod/kube-scheduler-k8s                                     1/1     Running   1          2d1h
metallb-system   pod/controller-76b56f7897-8nqrl                            1/1     Running   0          2d1h
metallb-system   pod/speaker-wclwv                                          1/1     Running   0          2d1h

NAMESPACE   NAME                                     CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                            STORAGECLASS   REASON   AGE
            persistentvolume/gitlab-data-pv          10Gi       RWO            Retain           Bound    default/gitlab-data-pvc                                  2d1h
            persistentvolume/gitlab-postgresql-pv    10Gi       RWO            Retain           Bound    default/gitlab-postgresql-pvc                            2d1h
            persistentvolume/redmine-data-pv         10Gi       RWO            Retain           Bound    default/redmine-data-pvc                                 2d1h
            persistentvolume/redmine-logs-pv         10Gi       RWO            Retain           Bound    default/redmine-logs-pvc                                 2d1h
            persistentvolume/redmine-postgresql-pv   10Gi       RWO            Retain           Bound    default/redmine-postgresql-pvc                           2d1h
            persistentvolume/registry-pv             5Gi        RWO            Retain           Bound    default/registry-pvc                                     2d1h

NAMESPACE   NAME                                           STATUS   VOLUME                  CAPACITY   ACCESS MODES   STORAGECLASS   AGE
default     persistentvolumeclaim/gitlab-data-pvc          Bound    gitlab-data-pv          10Gi       RWO                           2d1h
default     persistentvolumeclaim/gitlab-postgresql-pvc    Bound    gitlab-postgresql-pv    10Gi       RWO                           2d1h
default     persistentvolumeclaim/redmine-data-pvc         Bound    redmine-data-pv         10Gi       RWO                           2d1h
default     persistentvolumeclaim/redmine-logs-pvc         Bound    redmine-logs-pv         10Gi       RWO                           2d1h
default     persistentvolumeclaim/redmine-postgresql-pvc   Bound    redmine-postgresql-pv   10Gi       RWO                           2d1h
default     persistentvolumeclaim/registry-pvc             Bound    registry-pv             5Gi        RWO                           2d1h

NAMESPACE        NAME                                                    TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)                                      AGE
default          service/gitlab                                          ClusterIP      10.106.179.134   <none>           10080/TCP,10022/TCP                          2d
default          service/gitlab-postgresql                               ClusterIP      10.97.21.15      <none>           5432/TCP                                     2d1h
default          service/gitlab-redis                                    ClusterIP      10.96.190.53     <none>           6379/TCP                                     2d1h
default          service/kubernetes                                      ClusterIP      10.96.0.1        <none>           443/TCP                                      2d1h
default          service/redmine                                         ClusterIP      10.106.81.130    <none>           10083/TCP                                    2d1h
default          service/redmine-postgresql                              ClusterIP      10.98.84.136     <none>           5432/TCP                                     2d1h
default          service/registry                                        ClusterIP      10.110.0.223     <none>           5000/TCP                                     2d1h
ingress-system   service/my-release-ingress-nginx-controller             LoadBalancer   10.101.3.143     192.168.10.220   80:31098/TCP,443:31827/TCP,10022:32075/TCP   42m
ingress-system   service/my-release-ingress-nginx-controller-admission   ClusterIP      10.97.80.98      <none>           443/TCP                                      42m
kube-system      service/kube-dns                                        ClusterIP      10.96.0.10       <none>           53/UDP,53/TCP,9153/TCP                       2d1h
metallb-system   service/webhook-service                                 ClusterIP      10.99.227.217    <none>           443/TCP                                      2d1h

NAMESPACE   NAME                                        CLASS   HOSTS                         ADDRESS          PORTS     AGE
default     ingress.networking.k8s.io/example-ingress   nginx   example.tsuchinokometal.com   192.168.10.220   80, 443   2d

動作確認

GitLabにログインできるか確認します。
パスワードは環境変数で指定しているやつです。

gitlab_redmine_integrate_k8s_01.png

適当にプロジェクト作ってContainer Registryにアクセスします。
エラーが出ずにページが表示されればRegistryとの連携がうまくいってると思います。

gitlab_redmine_integrate_k8s_02.png

Registry使えるか確認します。
pushもできました。

% docker login example.tsuchinokometal.com         
Username: root
Password: 
Login Succeeded
% docker push example.tsuchinokometal.com/root/test
Using default tag: latest
The push refers to repository [example.tsuchinokometal.com/root/test]
7f8d8407f2d9: Layer already exists 
af7ed92504ae: Layer already exists 
latest: digest: sha256:56deaac7ef04ba1bf16a344fa2a756cec6b7ee34d7b17b5c99232ab0ad2d5ee2 size: 740

sshでgit使えるか確認します。

% nmap -p 10022 example.tsuchinokometal.com                     
Starting Nmap 7.92 ( https://nmap.org ) at 2022-08-14 11:29 JST
Nmap scan report for example.tsuchinokometal.com (192.168.10.220)
Host is up (0.0040s latency).

PORT      STATE SERVICE
10022/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.28 seconds
% git clone ssh://git@example.tsuchinokometal.com:10022/root/test.git
Cloning into 'test'...
Warning: Permanently added '[example.tsuchinokometal.com]:10022' (ED25519) to the list of known hosts.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

Redmineを確認します。
GitLabのRepository連携も確認できました。
詳しくはこちら をご確認ください。

gitlab_redmine_integrate_k8s_03.png

よさそうですね。