Argo CD

2022-07-29  本文已影响0人  87d6dc4b11a7
ArgoCD.png

Argo CD简介

Argo CD是一款基于 kubernetes 的声明式的Gitops 持续部署工具。

  1. 应用程序定义、配置和环境都是声明式的,并受版本控制
  2. 应用程序部署和生命周期管理都是自动化的、可审计的,并且易于理解。

架构

architecture.png

在 Kubernetes 集群中部署 Argo CD

安装 OLM 组件

[root@localhost ~]# curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.21.2/install.sh -o install.sh
[root@localhost ~]# chmod +x install.sh
[root@localhost ~]# ./install.sh v0.21.2
# 验证安装结果,安装成功后,会创建olm和operators两个命名空间
[root@localhost ~]# kubectl get ns
NAME              STATUS   AGE
default           Active   49d
jenkins           Active   49d
kube-node-lease   Active   49d
kube-public       Active   49d
kube-system       Active   49d
kubekey-system    Active   49d
olm               Active   6h16m
operators         Active   6h16m
# 验证OLM命名空间中Pods
[root@localhost ~]#kubectl get pods -n olm
NAME                                READY   STATUS    RESTARTS   AGE
olm-operator-5b58594fc8-bzpq2       1/1     Running   0          2m10s
catalog-operator-6d578c5764-l5f5t   1/1     Running   0          2m10s
packageserver-7495fbf449-w4w6h      1/1     Running   0          80s
packageserver-7495fbf449-9jmpj      1/1     Running   0          80s
operatorhubio-catalog-pnsc7         1/1     Running   0          81s

安装 Argo CD Operator

1、为operator创建命名空间

[root@localhost yaml]# kubectl create namespace argocd
namespace/argocd created

2、Operator Catalog

[root@localhost yaml]# kubectl create -n olm -f deploy/catalog_source.yaml
catalogsource.operators.coreos.com/argocd-catalog created
[root@localhost yaml]# kubectl get catalogsources -n olm
NAME                    DISPLAY               TYPE   PUBLISHER           AGE
argocd-catalog          Argo CD Operators     grpc   Argo CD Community   8s
operatorhubio-catalog   Community Operators   grpc   OperatorHub.io      6h39m
[root@localhost yaml]# kubectl get pods -n olm -l olm.catalogSource=argocd-catalog
NAME                   READY   STATUS    RESTARTS   AGE
argocd-catalog-876rg   1/1     Running   0          17s

3、Operator Group

[root@localhost yaml]# kubectl create -n argocd -f deploy/operator_group.yaml
operatorgroup.operators.coreos.com/argocd-operator created
[root@localhost yaml]# kubectl get operatorgroups -n argocd
NAME              AGE
argocd-operator   12s

4、Subscription

[root@localhost yaml]# kubectl create -n argocd -f deploy/subscription.yaml
subscription.operators.coreos.com/argocd-operator created
[root@localhost yaml]# kubectl get subscriptions -n argocd
NAME              PACKAGE           SOURCE           CHANNEL
argocd-operator   argocd-operator   argocd-catalog   alpha
[root@localhost yaml]# kubectl get installplans -n argocd
NAME            CSV                      APPROVAL    APPROVED
install-r7lwx   argocd-operator.v0.3.0   Automatic   true
[root@localhost yaml]# kubectl get pods -n operators
NAME                                                  READY   STATUS    RESTARTS   AGE
argocd-operator-controller-manager-65b8f9468b-t6hqw   2/2     Running   5          7h48m

安装Argo CD实例

[root@localhost yaml]# kubectl create -n argocd -f examples/argocd-basic.yaml
[root@localhost yaml]# kubectl get cm,secret,deploy -n argocd
NAME                                       DATA   AGE
configmap/argocd-cm                        16     7h2m
configmap/argocd-gpg-keys-cm               0      7h2m
configmap/argocd-operator-manager-config   1      7h36m
configmap/argocd-rbac-cm                   3      7h2m
configmap/argocd-ssh-known-hosts-cm        1      7h2m
configmap/argocd-tls-certs-cm              0      7h2m
configmap/example-argocd-ca                1      7h2m
configmap/kube-root-ca.crt                 1      20h

NAME                                                              TYPE                                  DATA   AGE
secret/argocd-operator-controller-manager-token-4q2ff             kubernetes.io/service-account-token   3      7h36m
secret/argocd-secret                                              Opaque                                5      7h2m
secret/default-token-jbw82                                        kubernetes.io/service-account-token   3      20h
secret/example-argocd-argocd-application-controller-token-4m9vk   kubernetes.io/service-account-token   3      7h2m
secret/example-argocd-argocd-dex-server-token-sw64k               kubernetes.io/service-account-token   3      7h2m
secret/example-argocd-argocd-redis-ha-token-tn6vv                 kubernetes.io/service-account-token   3      7h2m
secret/example-argocd-argocd-server-token-twjg2                   kubernetes.io/service-account-token   3      7h2m
secret/example-argocd-ca                                          kubernetes.io/tls                     3      7h2m
secret/example-argocd-cluster                                     Opaque                                1      7h2m
secret/example-argocd-default-cluster-config                      Opaque                                4      7h2m
secret/example-argocd-tls                                         kubernetes.io/tls                     2      7h2m

NAME                                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/example-argocd-dex-server    1/1     1            1           7h2m
deployment.apps/example-argocd-redis         1/1     1            1           7h2m
deployment.apps/example-argocd-repo-server   1/1     1            1           7h2m
deployment.apps/example-argocd-server        1/1     1            1           7h2m
[root@localhost yaml]# kubectl get svc -n argocd
NAME                                                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
argocd-operator-controller-manager-metrics-service   ClusterIP   10.233.2.132    <none>        8443/TCP                     7h36m
example-argocd-dex-server                            ClusterIP   10.233.35.172   <none>        5556/TCP,5557/TCP            7h3m
example-argocd-metrics                               ClusterIP   10.233.16.0     <none>        8082/TCP                     7h3m
example-argocd-redis                                 ClusterIP   10.233.28.175   <none>        6379/TCP                     7h3m
example-argocd-repo-server                           ClusterIP   10.233.58.219   <none>        8081/TCP,8084/TCP            7h3m
example-argocd-server                                NodePort    10.233.40.116   <none>        80:30080/TCP,443:30443/TCP   7h3m
example-argocd-server-metrics                        ClusterIP   10.233.53.110   <none>        8083/TCP                     7h3m

yaml文件参考:https://github.com/argoproj-labs/argocd-operator

获取登录密码

kubectl -n argocd get secret example-argocd-cluster -o jsonpath='{.data.admin\.password}' | base64 -d
image.png
上一篇 下一篇

猜你喜欢

热点阅读