未安装ArgoCD参考GitOps实践之kubernetes部署Argocd

1. 查看Argocd Service

可以看到是ClusterIP,因此不能从外部直接访问Argocd的WEB-UI

# kubectl get svc -n argocdNAME                                      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGEargocd-applicationset-controller          ClusterIP   10.96.52.109            7000/TCP,8080/TCP            25dargocd-dex-server                         ClusterIP   10.96.57.217            5556/TCP,5557/TCP,5558/TCP   25dargocd-metrics                            ClusterIP   10.96.153.115           8082/TCP                     25dargocd-notifications-controller-metrics   ClusterIP   10.96.207.83            9001/TCP                     25dargocd-redis                              ClusterIP   10.96.112.222           6379/TCP                     25dargocd-repo-server                        ClusterIP   10.96.240.85            8081/TCP,8084/TCP            25dargocd-server                             ClusterIP   10.96.65.68             80/TCP,443/TCP               25dargocd-server-metrics                     ClusterIP   10.96.16.178            8083/TCP                     25ds

2. 检查Ingress控制器是否正常。

打算使用ingress-nginx来暴露应用,也可以使用Traefik等。

# kubectl get pods -n ingress-nginxNAME                             READY   STATUS    RESTARTS         AGEingress-nginx-controller-bnmpt   1/1     Running   26               25dingress-nginx-controller-cfblk   1/1     Running   28 (5d23h ago)   25d

3. 查看Secret

# kubectl get secret -n argocdNAME                                           TYPE                                  DATA   AGEargocd-application-controller-token-f9qj7      kubernetes.io/service-account-token   3      25dargocd-applicationset-controller-token-r5vqk   kubernetes.io/service-account-token   3      25dargocd-dex-server-token-hzwkt                  kubernetes.io/service-account-token   3      25dargocd-initial-admin-secret                    Opaque                                1      25dargocd-notifications-controller-token-75csv    kubernetes.io/service-account-token   3      25dargocd-notifications-secret                    Opaque                                0      25dargocd-redis-token-78522                       kubernetes.io/service-account-token   3      25dargocd-repo-server-token-6f2x9                 kubernetes.io/service-account-token   3      25dargocd-secret                                  Opaque                                5      25d

4. 配置Ingress规则。

# cat argocd-ingress.yaml apiVersion: networking.k8s.io/v1kind: Ingressmetadata:  name: argocd-server-ingress  namespace: argocd  annotations:    nginx.io/tls-acme: "true"    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" # 后端使用tls协议,设置代理后端服务器的代理协议类型,默认为 HTTP    nginx.ingress.kubernetes.io/force-ssl-redirect: "true" # 设置当前虚拟主机支持 HTTPS 请求时,是否将 HTTP 的请求强制跳转到 HTTPS 端口,全局默认为 true    nginx.ingress.kubernetes.io/ssl-passthrough: "true" # ssl透传spec:  ingressClassName: nginx    # 使用 nginx 的 IngressClass(关联的 ingress-nginx 控制器)  rules:     # 规则    - host: argocd.k8s.local    # 虚拟主机的FQDN      http:        paths:          - path: /            pathType: Prefix    # Prefix前缀匹配            backend:              service:                name: argocd-server                port:                  name: https  tls:    # 配置 tls 证书  - hosts:    - argocd.k8s.local    secretName: argocd-secret   "引用的secret"# kubectl apply -f argocd-ingress.yaml ingress.networking.k8s.io/argocd-server-ingress unchanged

5. 查看Ingress配置

不过需要注意大部分Ingress控制器都不是直接转发到Service
而是只是通过Service来获取后端的Endpoints列表,直接转发到Pod,这样可以减少网络跳转,提高性能。

# kubectl get ingress -n argocdNAME                    CLASS   HOSTS              ADDRESS               PORTS     AGEargocd-server-ingress   nginx   argocd.k8s.local   10.0.0.11,10.0.0.12   80, 443   24d# kubectl describe ingress argocd-server-ingress -n argocdName:             argocd-server-ingressNamespace:        argocdAddress:          xxxxxxxxDefault backend:  default-http-backend:80 ()TLS:  argocd-secret terminates argocd.k8s.localRules:  Host              Path  Backends  ----              ----  --------  argocd.k8s.local                      /   argocd-server:https (192.168.2.49:8080)Annotations:        nginx.ingress.kubernetes.io/backend-protocol: HTTPS                    nginx.ingress.kubernetes.io/force-ssl-redirect: true                    nginx.ingress.kubernetes.io/ssl-passthrough: true                    nginx.io/tls-acme: trueEvents:             

6. 配置本地hosts解析。

echo "xxxxx argocd.k8s.local" 

7. 访问argocd WEB-UI


我们一直奔跑在进步的旅途