ArgoCD 安装-内网安装

ArgoCD是什么请自行百度,这里只是记录安装步骤。

一、准备:
1、一个k8s集群
2、下载安装yaml文件

$ wget https://raw.githubusercontent.com/argoproj/argo-cd/v1.5.5/manifests/install.yaml

二、开始安装:
1、创建argocd命名空间

$ kubectl create namespace argocd

2、我安装的服务器只能用内网,所以我打开了install.yaml,找到里面的所有镜像,在有网的地方下载了,再拷贝到了服务器,
如:image: argoproj/argocd:v1.5.5
外网电脑:

$ docker pull argoproj/argocd:v1.5.5
$ docker save -o argocd1.5.5.tar argoproj/argocd:v1.5.5

把argocd1.5.5.tar拷贝到内网服务器,在内网服务器执行:

$ docker load < argocd1.5.5.tar

这里所有的镜像都是这样操作,把install.yaml也拷贝到内网服务器,由于后面需要使用ssh和bitbucket进行认证,这里需要生成一对sshkey。

#遇到提示需要输入,全部按回车键。
$ ssh-keygen -t rsa
#生成一个名字是ssh-key-secret的k8s secret。
$ kubectl create secret generic ssh-key-secret -n argocd --from-file=ssh-privatekey=/root/.ssh/id_rsa --from-file=ssh-publickey=/root/.ssh/id_rsa.pub

修改install.yaml,使得argocd-server的pod可以拥有这一对sshkey,把argocd-server的deployment的volumeMounts和volumes修改为:

     volumeMounts:
        - mountPath: /app/config/ssh
          name: ssh-known-hosts
        - mountPath: /app/config/tls
          name: tls-certs
        - name: secret-volume
          readOnly: true
          mountPath: /etc/secret-volume
      serviceAccountName: argocd-server
      volumes:
      - emptyDir: {}
        name: static-files
      - configMap:
          name: argocd-ssh-known-hosts-cm
        name: ssh-known-hosts
      - configMap:
          name: argocd-tls-certs-cm
        name: tls-certs
      - secret:
          secretName: ssh-key-secret
        name: secret-volume

volumeMounts中添加的部分:

 - name: secret-volume
   readOnly: true
   mountPath: /etc/secret-volume

volumes中添加的部分:

- secret:
    secretName: ssh-key-secret
  name: secret-volume  

执行下面命令进行部署

$ kubectl apply -n argocd -f install.yaml
#执行检查是否所有pod都是running状态
$ kubectl get pods -n argocd

三、配置域名访问方式
1、新增ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: argocd-server-http-ingress
  namespace: argocd
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: argocd-server
          servicePort: http
    host: example.argocd.com
  tls:
  - hosts:
    - example.argocd.com
    secretName: argocd-secret

2、执行

$ kubectl create -n argocd -f ingress.yaml

3、编辑argocd-server deployment以将–insecure标志添加 到argocd-server命令:

spec:
  template:
    spec:
      name: argocd-server
      containers:
      - command:
        - /argocd-server
        - --staticassets
        - /shared/app
        - --repo-server
        - argocd-repo-server:8081
        - --insecure  #追加

将k8s集群某一台宿主机的ip加上网址,添加到hosts文件中,添加后可通过浏览器访问example.argocd.com

10.11.38.29  example.argocd.com

到此ArgoCD的安装就完成了,登录的用户名是admin,密码为argo-server的pod名字,可以通过命令查找出来。

$ kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2

登录这里我遇到一个坑,用pod名字作为密码无论怎么都登录不成功,提示用户名或者密码错误,最后只能修改密码来登录。密码要先通过Bcrypt进行加密,网址https://www.jisuan.mobi/p163u3BN66Hm6JWx.html。

#密码A123456
$  kubectl -n argocd patch secret argocd-secret   -p '{"stringData": {
      "admin.password": "$2a$10$88NHgAw3gSbPmMGvPH8wl.E.wh/JpxF6LpAkN.3YzI8vCKqz92rpi",
      "admin.passwordMtime": "'$(date +%FT%T%Z)'"
    }}'

至此,安装完成。
在这里插入图片描述

参考文章:https://blog.csdn.net/weixin_37546425/article/details/105137539
https://argoproj.github.io/argo-cd/getting_started/#port-forwarding

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐