728x90

 

경로 설정 방법 2가지

1. join된 모든 노드에 containerd config.toml파일 설정

2. 실행된 pod에 secret생성하여 연결하기

 

join된 모든 노드에 containerd config.toml파일 설정

[root@docker06 ~]# vim /etc/containerd/config.toml
      [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
       [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
        endpoint = ["https://registry-1.docker.io"]
       [plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
        endpoint = ["https://ghcr.io"]
      [plugins."io.containerd.grpc.v1.cri".registry.configs]
       [plugins."io.containerd.grpc.v1.cri".registry.configs."ghcr.io".auth]
        username = "${github 로그인계정ID}"
        password = "${생성한 token}" # 예시) ghp_irQQQQQQQQQQQQQQQQQQQQQQQQQ
[root@docker06 ~]# systemctl restart containerd

 

실행된 pod에 secret생성하여 연결하기

kubectl create secret docker-registry ghcrkey --docker-server=https://ghcr.io --docker-username=Parkjinman --docker-password=ghp_irQQQQQQQQQQQQQQQQQQQQQQQ --docker-email=Parkjinman@naver.com --namespace test
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "nexus-charts.fullname" . }}
  labels:
    {{- include "nexus-charts.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "nexus-charts.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "nexus-charts.selectorLabels" . | nindent 8 }}
    spec:
      imagePullSecrets: # 생성한 secret과 연결
        - name: ghcrkey
      serviceAccountName: {{ include "nexus-charts.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      initContainers:
        - name: configure-mount-permission
          image: ghcr.io/cloudmoa/busybox
          command: ['sh', '-c', 'chown -R 200:200 /nexus-data']
          volumeMounts:
          - name: nexus-data
            mountPath: /nexus-data
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 8081
              protocol: TCP
            - name: docker
              containerPort: 5000
              protocol: TCP
          volumeMounts:
            - name: nexus-data
              mountPath: /nexus-data
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      volumes:
        - name: nexus-data
          persistentVolumeClaim:
            claimName: {{ include "nexus-charts.fullname" . }}

imagePullSecrets:
    - name: ghcrkey

이 값을 추가해서 생성한 secret과 연결해야한다.

개인적으로 2번째 방법은 추천하지 않는다. helm에서 image를 2번이상 pull받아야 하는 경우 1번은 정상적으로 받지만 2번째부터 pull받다가 에러도 뜨지않고 멈추는 증상이 있다. 원인은 찾지 못했다.

728x90
TOP