add nginx deployment test
This commit is contained in:
34
k3s/zidonghua_自动化/deployment.yaml
Normal file
34
k3s/zidonghua_自动化/deployment.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-test
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx:stable-alpine
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nginx-service
|
||||
spec:
|
||||
selector:
|
||||
app: nginx
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
type: ClusterIP
|
||||
22
k3s/zidonghua_自动化/my-app-argocd.yaml
Normal file
22
k3s/zidonghua_自动化/my-app-argocd.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: k3s-configs-app
|
||||
namespace: argocd # 必须部署在 ArgoCD 所在的命名空间
|
||||
spec:
|
||||
project: default # 使用默认项目
|
||||
source:
|
||||
repoURL: 'https://git.u9.net3w.com/fei/k3s-configs.git'
|
||||
targetRevision: HEAD # 对应主分支(main/master)
|
||||
path: '.' # 配置文件在仓库中的根目录
|
||||
destination:
|
||||
server: 'https://kubernetes.default.svc' # 部署到 ArgoCD 所在的当前集群
|
||||
namespace: my-deploy-ns # 目标命名空间(会自动在该下创建资源)
|
||||
|
||||
# 自动化部署的关键配置
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true # 自动删除 Git 中已不存在的资源
|
||||
selfHeal: true # 如果手动改了集群,ArgoCD 会自动修复回 Git 的状态
|
||||
syncOptions:
|
||||
- CreateNamespace=true # 如果目标命名空间不存在,则自动创建
|
||||
1
k3s/zidonghua_自动化/note.md
Normal file
1
k3s/zidonghua_自动化/note.md
Normal file
@@ -0,0 +1 @@
|
||||
kubectl apply -f my-app-argocd.yaml
|
||||
Reference in New Issue
Block a user