Argo CD 是用于 Kubernetes 的声明性 GitOps 连续交付工具。
部署
部署方式比较简单,我们就按照官方文档安装
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
暴露
CLB
部署完成之后,默认是 ClusterIP,为了互联网访问,我们改成 LoadBalancer
:
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
Ingress
如果要使用 ALB 来暴露服务,我们需要为 argocd-server 再创建一个 service。
apiVersion: v1
kind: Service
metadata:
annotations:
alb.ingress.kubernetes.io/backend-protocol-version: HTTP2 #This tells AWS to send traffic from the ALB using HTTP2. Can use GRPC as well if you want to leverage GRPC specific features
labels:
app: argogrpc
name: argogrpc
namespace: argocd
spec:
ports:
- name: "443"
port: 443
protocol: TCP
targetPort: 8080
selector:
app.kubernetes.io/name: argocd-server
sessionAffinity: None
type: ClusterIP
然后创建 ingress 文件。
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: argocd
name: argocd
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/backend-protocol: HTTPS
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/group.name: wzlinux
alb.ingress.kubernetes.io/conditions.argogrpc: |
[{"field":"http-header","httpHeaderConfig":{"httpHeaderName": "Content-Type", "values":["application/grpc"]}}]
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:eu-west-1:921283538843:certificate/e55a72ae-d9b5-4f77-bf6d-242691105231
alb.ingress.kubernetes.io/target-type: ip
spec:
rules:
- host: cd.wzlinux.com
http:
paths:
- pathType: ImplementationSpecific
backend:
service:
name: argogrpc
port:
number: 443
- backend:
service:
name: argocd-server
port:
number: 443
pathType: ImplementationSpecific
为 Argo CD 配置 Ingress 请查看下面文档:
https://argoproj.github.io/argo-cd/operator-manual/ingress/#aws-application-load-balancers-albs-and-classic-elb-http-mode
有关 ALB Ingress annotations 使用方法,请查看下面文档:
https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.2/guide/ingress/annotations/
演示
登陆
打开 CLB 地址后,我们首先获取 argocd 的密码:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
账户是 admin,密码就是刚刚获取的,输入登陆即可。
配置仓库
配置 APP
我在代码仓库的根目录创建了一个文件夹k8s
,里面存放了两个文件,一个是deployment.yaml
,一个是service.yaml
。
因为我们的 argocd 就在 EKS 中运行,所以和 EKS 相关权限方面变得比较简单。
测试
配置好之后,我们去修改 k8s 里面的清单文件,然后点击 SYNC 进行发布即可。