EKS 训练营-CD Argocd(13)

Argo CD 是用于 Kubernetes 的声明性 GitOps 连续交付工具。

image-20210607121806875

部署

部署方式比较简单,我们就按照官方文档安装

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,密码就是刚刚获取的,输入登陆即可。

image-20210625230533505

配置仓库

image-20210607151719331

配置 APP

我在代码仓库的根目录创建了一个文件夹k8s,里面存放了两个文件,一个是deployment.yaml,一个是service.yaml

image-20210607153054547

因为我们的 argocd 就在 EKS 中运行,所以和 EKS 相关权限方面变得比较简单。

测试

配置好之后,我们去修改 k8s 里面的清单文件,然后点击 SYNC 进行发布即可。

image-20210607153217168

欢迎大家扫码关注,获取更多信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值