Kubernetes – ArgoCD 설치

By | 2022년 10월 28일
Table of Contents

Kubernetes – ArgoCD 설치

ArgoCD 설치

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl get svc argocd-server -n argocd

타입을 NodePort 로 변경해준다.

kubectl edit svc argocd-server -n argocd
---------------------------
spec:
  clusterIP: 10.107.7.97
  clusterIPs:
  - 10.107.7.97
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: http
    port: 80
    nodePort: 30100            # 여기
    targetPort: 8080
 - name: https
   port: 443
   protocol: TCP
   targetPort: 8080
  selector:
    app.kubernetes.io/name: argocd-server
  sessionAffinity: None
  type: NodePort                # 여기
---------------------------
kubectl get svc argocd-server -n argocd

https://워커노드IP:30100/ 로 접속할 수 있다.
(HTTPS 접속이고 경고가 뜨지만 무시하고 접속할 수 있다.)

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo

admin/비밀번호 를 이용해 로그인할 수 있다.

https 비활성화

아래 명령으로 https 전환이 강제되는 것을 확인할 수 있다.

skyer9@notebook:~/work/cert2$ kubectl get svc -n argocd
NAME                                      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
argocd-server                             ClusterIP   10.98.113.43     <none>        80/TCP,443/TCP               7d22h

curl http://10.98.113.43/
<a href="https://10.98.113.43/">Temporary Redirect</a>.

server.insecure: "true" 을 추가해 준다.

kubectl edit cm argocd-cmd-params-cm -n argocd

......
apiVersion: v1
data:
  server.insecure: "true"
......

생성되어 있는 Pod 를 삭제한다.

kubectl get pod -n argocd
kubectl delete pod argocd-server-7b4888c795-qkm4n -n argocd
kubectl get pod -n argocd
kubectl get svc -n argocd
curl http://10.98.113.43/

SSL 인증서 적용하기

kubectl create secret tls argocd-server-tls \
  --cert=/home/skyer9/cert/fullchain.pem \
  --key=/home/skyer9/cert/privkey.pem \
  -n argocd
kubectl patch configmap argocd-cmd-params-cm -n argocd --patch '{"data":{"server.insecure":"false"}}'
kubectl patch deployment argocd-server -n argocd --patch '
{
  "spec": {
    "template": {
      "spec": {
        "containers": [
          {
            "name": "argocd-server",
            "volumeMounts": [
              {
                "name": "tls-cert",
                "mountPath": "/app/config/tls",
                "readOnly": true
              }
            ]
          }
        ],
        "volumes": [
          {
            "name": "tls-cert",
            "secret": {
              "secretName": "argocd-server-tls"
            }
          }
        ]
      }
    }
  }
}'
kubectl patch svc argocd-server -n argocd --patch '
{
  "spec": {
    "ports": [
      {
        "name": "http",
        "port": 80,
        "nodePort": 30100,
        "targetPort": 8080
      },
      {
        "name": "https",
        "port": 443,
        "nodePort": 30443,
        "protocol": "TCP",
        "targetPort": 8080
      }
    ]
  }
}'
kubectl rollout restart deployment argocd-server -n argocd
kubectl rollout status deployment argocd-server -n argocd

https://워커노드IP:30443/ 로 접속할 수 있다.

"주의 요함" 이라는 문구가 남아있을 수 있다.
이럴 때는 다른 브라우저(엣지, 사파리 등등) 를 이용해 접속하면 "주의 요함" 문구가 표시되지 않는 것을 확인할 수 있다.

답글 남기기