1.K8S可以使用yml部署资源
apiVersion: apps/v1
kind: Deployment
metadata:
name: gateway-app
spec:
replicas: 1
selector:
matchLabels:
app: gateway-app
template:
metadata:
labels:
app: gateway-app
spec:
containers:
- name: gateway-app
image: registry.cn-beijing.aliyuncs.com/205erp/gateway-app:2024-06-04-10-42-26
ports:
- containerPort: 8080
2.高级配置
1.添加容器环境变量
2.文件挂载
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
env: # 添加环境变量配置
- name: MY_ENV_VAR
value: "Hello Kubernetes"
volumeMounts: # 添加日志挂载配置
- name: nginx-logs
mountPath: /var/log/nginx
volumes: # 定义挂载卷
- name: nginx-logs
hostPath: # 使用HostPath类型挂载到主机
path: /path/on/host/for/nginx/logs # 这里填写主机上的日志目录路径
type: DirectoryOrCreate # 如果需要自动创建目录
FILE_CONTENT=$(cat k8s.yml | sed 's/$/\n/g')
curl -X POST \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text", "text": {"content": "审核,黑米-最新镜像:'${FILE_CONTENT}'"}}' \
https://oapi.dingtalk.com/robot/send?access_token=ddaea71f9ed09a0cd0fe1a28e18fadb618a4e0cee829c0534d48b3273dd9e644
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » k8s使用yml文件部署
发表评论 取消回复