java系统找不到指定文件怎么解决
331
2022-10-23
Gitops
1. GitOps
1. argoCD
官网: https://argoproj.github.io/ 1. 安装
1. Helm
1. 添加 repo
# 1. 添加 [root@localhost argo]# helm repo add argo-cd https://argoproj.github.io/argo-helm # 2. 更新 [root@localhost argo]# helm repo update # 3. 查看 [root@localhost argo]# helm search repo argo-cd | grep argo-cd/argo-cd NAME CHART VERSION APP VERSION DESCRIPTION argo-cd/argo-cd 3.21.0 2.1.2 A Helm chart for ArgoCD, a declarative, GitOps ...
2. 编辑 values.yaml
根据自己的环境情况,添加、修改适应于自己环境的编排参数
[root@localhost argo]# cat values.yaml server: ingress: enabled: true annotations: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/force-ssl-redirect: "true" nginx.ingress.kubernetes.io/ssl-passthrough: "true" nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" hosts: - argocd-test.local.com http: paths: - backend: serviceName: argocd-server servicePort: 80 path: / tls: - secretName: test-http-cert hosts: - argocd-test.local.com
3. 安装
[root@localhost argo]# helm upgrade --install argocd argo-cd/argo-cd -f values.yaml -n argocd Release "argocd" does not exist. Installing it now. NAME: argocd LAST DEPLOYED: Mon Aug 23 16:02:30 2021 NAMESPACE: argocd STATUS: deployed REVISION: 1 TEST SUITE: None
4. 获取密码
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
5. 登录 web
使用 values.yaml 定义的 ingress 地址进行登录即可:argocd-test.local.com
2. 使用
1. create app
Application -> NEW APP
3. 清除缓存
在 chart 编排(包括values文件)发生变化但版本号不变的情况下,argocd 不会拉取新的编排。这时需要执行以下步骤来删除缓存
1. 删除 server 记录
[root@localhost ~]$ kubectl -n argocd exec -it argocd-repo-server-name sh $ cd /tmp && ls $ cd helmxxxx && ls $ cd ../& ls $ rm -f helm-charts-name
2. 删除 redis 记录
[root@localhost ~]$ kubectl -n argocd exec -it argocd-redis-ha-server-xx sh /data $ redis-cli 127.0.0.1:6379> keys *helm-charts-name | version-num 127.0.0.1:6379> del *helm-charts-name | version-num [key ...]
3. 重新同步
执行 argocd sync 进行同步
4. 设置
1. helm repo
Settings -> Repositories -> Connect Repo using HTTPS and submit below details
Type : helm
Name : repo 名字
2. create project
5. 客户端管理
Argo CD Git 仓库发布页面 或 使用命令获取最新版本
VERSION=$(curl --silent "| grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
VERSION 在下面的命令中替换为你要下载的 Argo CD 版本:
curl -sSL -o /usr/local/bin/argocd +x /usr/local/bin/argocd
5. 客户端
1. 安装
Argo CD Git 仓库发布页面 或 使用命令获取最新版本
[root@localhost ~]# VERSION=$(curl --silent "| grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
VERSION 在下面的命令中替换为你要下载的 Argo CD 版本:
[root@localhost ~]# curl -sSL -o /usr/local/bin/argocd ~]# chmod +x /usr/local/bin/argocd
2. 服务端管理
格式: argocd [flags]
1. 登录
格式: argocd login SERVER [flags]
1. username & password
Login to Argo CD using a username and password
# 不使用 --grpc-web [root@localhost ~]# argocd login argocd-test.hai.com WARN[0000] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web. Username: admin Password: 'admin:login' logged in successfully Context 'argocd-test.hai.com' updated # 使用 --grpc-web [root@localhost ~]# argocd login argocd-test.hai.com --grpc-web Username: admin Password: 'admin:login' logged in successfully Context 'argocd-test.hai.com' updated
2. SSO
Login to Argo CD using SSO
3. k8s API
Configure direct access using Kubernetes API server
[root@localhost ~]# argocd login argocd-test.hai.com --core
2. 退出
格式: argocd logout CONTEXT [flags]
[root@localhost ~]# argocd logout argocd-test.hai.com Logged out from 'argocd-test.hai.com'
3. 账号
1. add
添加 hai 这个账号:
编辑 修改密码
2. get
格式: argocd account get [flags] flags 选项: -a, --account string Account name. Defaults to the current account. -h, --help help for get -o, --output string Output format. One of: json|yaml|wide|name (default "wide")
查看当前账号信息 [root@localhost ~]# argocd account get Name: admin Enabled: true Capabilities: login Tokens: NONE 查看指定账号信息 [root@localhost ~]# argocd account get -a admin Name: admin Enabled: true Capabilities: login Tokens: NONE
3. list
格式: argocd account list [flags] flags 选项: -h, --help help for list -o, --output string Output format. One of: json|yaml|wide|name (default "wide")
列出账号 [root@localhost ~]# argocd account list NAME ENABLED CAPABILITIES admin true login
4. get-user-info
格式: argocd account get-user-info [flags] flags 选项: -h, --help help for get-user-info -o, --output string Output format. One of: yaml, json
[root@localhost ~]# argocd account get-user-info Logged In: true Username: admin Issuer: argocd Groups:
5. generate-token
格式: argocd account generate-token [flags] flags 选项: -a, --account string Account name. Defaults to the current account. -e, --expires-in string Duration before the token will expire. (Default: No expiration) (default "0s") -h, --help help for generate-token --id string Optional token id. Fall back to uuid if not value specified.
[root@localhost ~]# argocd account generate-token
FATA[0000] rpc error: code = Unknown desc = account 'admin' does not have apiKey capability
# Generate token for the currently logged in account
[root@localhost ~]# argocd account generate-token
# Generate token for the account with the specified name
[root@localhost ~]# argocd account generate-token --account
6. delete-token
格式: argocd account delete-token [flags] flags 选项: -a, --account string Account name. Defaults to the current account. -h, --help help for delete-token
# Delete token of the currently logged in account
[root@localhost ~]# argocd account delete-token ID
# Delete token of the account with the specified name
[root@localhost ~]# argocd account delete-token --account
7. update-password
4.权限控制
1. 编辑
2. 修改权限
案例一:
定义的单个 用户 所拥有的权限:
案例二:
案例三:
Argo CD项目有更多的特性。除了源和目的地之外,你还可以调优该项目中可以管理的Kubernetes资源列表。你可以生成令牌并自动化项目创建和管理。
案例四:
3.验证权限
本地
[root@localhost ~]# argocd admin settings rbac validate --policy-file somepolicy.csv
[root@localhost ~]# argocd admin settings rbac validate --namespace argocd
4. 测试权限
格式:argocd admin settings rbac can SOMEROLE ACTION RESOURCE SUBRESOURCE [flags]
[root@localhost ~]# argocd admin settings rbac can role:org-admin get applications --policy-file argocd-rbac-cm.yaml Yes [root@localhost ~]# argocd admin settings rbac can role:org-admin get clusters --policy-file argocd-rbac-cm.yaml Yes [root@localhost ~]# argocd admin settings rbac can role:org-admin create clusters 'somecluster' --policy-file argocd-rbac-cm.yaml No [root@localhost ~]# argocd admin settings rbac can role:org-admin create applications 'someproj/someapp' --policy-file argocd-rbac-cm.yaml Yes # Plain policy, without a default role defined [root@localhost ~]# argocd admin settings rbac can role:staging-db-admins get applications --policy-file policy.csv No [root@localhost ~]# argocd admin settings rbac can role:staging-db-admins get applications 'staging-db-admins/*' --policy-file policy.csv Yes # Argo CD augments a builtin policy with two roles defined, the default role # being 'role:readonly' - You can include a named default role to use: [root@localhost ~]# argocd admin settings rbac can role:staging-db-admins get applications --policy-file policy.csv --default-role role:readonly Yes [root@localhost ~]# argocd admin settings rbac can db-admins get applications 'staging-db-admins/*' --policy-file policy.csv Yes
5. 验证 argocd 中的权限
3. repo 管理
格式: argocd repo [flags]
1. 添加 repo
[root@localhost ~]# argocd repo add --username admin --password 123456
2.
再添加需要发布的项目像之前一样
[root@localhost ~]# argocd app create test01 --repo --path test --dest-server --dest-namespace default
3. 查看 repo
[root@localhost ~]# argocd repo list TYPE NAME REPO INSECURE OCI LFS CREDS STATUS MESSAGE PROJECT git false false false true Successful
4. 删除 repo
[root@localhost ~]# argocd repo rm app 管理
格式: argocd app [flags]
1. 创建 app
创建 app 有以下两种方式
1. git 仓库
创建一个 test-app ,指定仓库地址、应用路径、目标apiserver地址、目标namespace
argocd app create test-guest --repo --path test00 --dest-server --dest-namespace default
2. helm
2. 查看 app
1. 所有
[root@localhost ~]# argocd app list
2. 指定
查看 test-app
[root@localhost ~]# argocd app get test-app
3. 同步 app
主要是作用是,将 app 部署到 k8s 集群中
[root@localhost ~]# argocd app sync test-app
4. 修改参数
[root@localhost ~]# argocd app set my-app -p image.tag=v1.0.1
5. 删除 app
[root@localhost ~]# argocd app delete test-app
5. cluster 管理
格式: argocd cluster [flags]
1. 查看
[root@localhost ~]# argocd cluster list -o json
2. 添加
[root@localhost ~]# argocd cluster add example-cluster
3. 删除
[root@localhost ~]# argocd cluster rm example-cluster
6. 概念
1. 架构图
2. 组件
1. API 服务
API 服务是一个 gRPC/REST 服务,它暴露了 Web UI、CLI 和 CI/CD 系统使用的接口,主要有以下几个功能:
应用程序管理和状态报告 执行应用程序操作(例如同步、回滚、用户定义的操作) 存储仓库和集群凭据管理(存储为 K8S Secrets 对象) 认证和授权给外部身份提供者 RBAC Git webhook 事件的侦听器/转发器
2. 仓库服务
存储仓库服务是一个内部服务,负责维护保存应用程序清单 Git 仓库的本地缓存。当提供以下输入时,它负责生成并返回 Kubernetes 清单:
存储 URL revision 版本(commit、tag、branch) 应用路径 模板配置:参数、ksonnet 环境、helm values.yaml 等
3. 应用控制器
应用控制器是一个 Kubernetes 控制器,它持续 watch 正在运行的应用程序并将当前的实时状态与所期望的目标状态( repo 中指定的)进行比较。它检测应用程序的 OutOfSync 状态,并采取一些措施来同步状态,它负责调用任何用户定义的生命周期事件的钩子(PreSync、Sync、PostSync)。
10. 错误集
1. Unable to create application
解决方案:一
需要先创建 project, 请参考【4. 设置】节。Failed to load data
Unable to load data: Request has been terminated Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc
解决方案:一
通过 argocd-server 日志进行跟踪;
[root@localhost ~]$ kubectl get po -n argocd NAME READY STATUS RESTARTS AGE argocd-application-controller-74cdb5d457-lblgj 1/1 Running 0 40h argocd-dex-server-64b659bb9d-2trl6 1/1 Running 0 40h argocd-redis-54d5b56c99-gks79 1/1 Running 0 41d argocd-repo-server-575599bd9d-qpx9k 1/1 Running 0 40h argocd-server-847f4b6c59-g9zt7 1/1 Running 0 108s [root@localhost ~]$ kubectl logs -f --tail=5 argocd-server-847f4b6c59-g9zt7 -n argocd time="2021-09-28T02:58:14Z" level=warning msg="Failed to resync revoked tokens. retrying again in 1 minute: dial tcp 10.101.161.213:6379: i/o timeout"
6379 是 redis 服务的端口地址,因此认为是 redis 服务问题。
因为是测试环境,没有细查,直接删除 redis 容器,状态恢复。
3. xxx is not permitted in project test.
解决方案:一
Settings -> Projects -> proecte-name -> CLUSTER RESOURCE ALLOW LIST -> EDIT -> ADD RESOURCE
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~