Kubernetes高级工具Argo CD
https://argo-cd.readthedocs.io/en/stable/
Argo CD 是针对 Kubernetes 的声明式 GitOps 持续交付工具。
Argo CD 是一个为 Kubernetes 而生的,遵循声明式 GitOps 理念的持续部署(CD)工具。
Argo CD 可在 Git 存储库更改时自动同步和部署应用程序。
安装argo cd
[root@rocky01 canary] # kubectl create namespace argocd
[root@rocky01 canary] # kubectl config set-context context-lab --namespace argocd
[root@rocky01 canary] # kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
[root@rocky01 canary] # cat ingress-argocd.yml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:name: argocd-servernamespace: argocdannotations:kubernetes.io/ingress.class: "nginx"nginx.ingress.kubernetes.io/force-ssl-redirect: "true"nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:rules:- http:paths:- pathType: Prefixpath: /backend:service:name: argocd-serverport:name: httpshost: argocd.k8slab.iotls:- hosts:- argocd.k8slab.iosecretName: argocd-secret
[root@rocky01 canary] # kubectl create -f ingress-argocd.yml -n argocd
[root@rocky01 canary] # kubectl get svc | grep -w argocd-server
argocd-server ClusterIP 10.68.41.84 <none> 80/TCP,443/TCP 64m
argocd-server-metrics ClusterIP 10.68.141.115 <none> 8083/TCP 64m
[root@rocky01 canary] # kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
argocd-server <none> argocd.k8slab.io 192.168.5.239 80, 443 12m
[root@rocky01 canary] # curl -I argocd.k8slab.io
HTTP/1.1 308 Permanent Redirect
Date: Thu, 08 Aug 2024 19:03:26 GMT
Content-Type: text/html
Content-Length: 164
Connection: keep-alive
Location: https://argocd.k8slab.io
[root@rocky01 canary] # kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d # 获取admin的登陆密码
如果在访问Argo-CD页面的时候出现太多重定向的问题请参考:https://github.com/argoproj/argo-cd/issues/2953
[root@rocky01 canary] # argocd login argocd.k8slab.io
[root@rocky01 canary] # argocd app create guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path kustomize-guestbook --dest-server https://kubernetes.default.svc --dest-namespace default
[root@rocky01 canary] # alias argocdc='argocd --grpc-web'
[root@rocky01 canary] # argocd app sync guestbook
[root@rocky01 canary] # argocdc app get guestbook
Name: argocd/guestbook
Project: default
Server: https://kubernetes.default.svc
Namespace: argocd
URL: https://argocd.k8slab.io/applications/guestbook
Source:
- Repo: https://github.com/argoproj/argocd-example-apps.gitTarget: HEADPath: kustomize-guestbook
SyncWindow: Sync Allowed
Sync Policy: Manual
Sync Status: Synced to HEAD (d7927a2)
Health Status: HealthyGROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGEService argocd kustomize-guestbook-ui Synced Healthy service/kustomize-guestbook-ui created
apps Deployment argocd kustomize-guestbook-ui Synced Healthy deployment.apps/kustomize-guestbook-ui created
[root@rocky01 canary] # kubectl get svc | grep book
kustomize-guestbook-ui ClusterIP 10.68.125.77 <none> 80/TCP 11m
[root@rocky01 canary] # kubectl create ingress --rule="guestbook-ui.k8slab.io/=kustomize-guestbook-ui:80" --class=nginx guestbook-ui
ingress.networking.k8s.io/guestbook-ui created
[root@rocky01 canary] # kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
argocd-server <none> argocd.k8slab.io 192.168.5.239 80, 443 37m
guestbook-ui nginx guestbook-ui.k8slab.io 192.168.5.239 80 11s
[root@rocky01 canary] # curl -I guestbook-ui.k8slab.io
HTTP/1.1 200 OK
Date: Thu, 08 Aug 2024 19:28:21 GMT