k8s管理
1、定时任务
每min调用一次
apiVersion: batch/v1
kind: CronJob
metadata:
name: date
namespace: default
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- date
restartPolicy: OnFailure
---
2、hpa管理
cpu 50%
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: frontend-scaler
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: frontend
minReplicas: 3
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
___
3、
http liveness 存货探针
apiVersion: v1
kind: Pod
metadata:
name: liveness-http
spec:
containers:
- name: my-container
image: nginx
livenessProbe:
httpGet:
path: /health
port: 80
initialDelaySeconds: 20
failureThreshold: 1
4、部署
apiVersion: v1
kind: Pod
metadata:
name: chartmuseum
namespace: chartmuseum
labels:
app: chartmuseum
spec:
containers:
- name: chartmuseum
image: bitnami/chartmuseum:latest
ports:
- containerPort: 8080
volumeMounts:
- name: charts
mountPath: /charts
env:
- name: DEBUG
value: '1'
- name: STORAGE
value: local
- name: STORAGE_LOCAL_ROOTDIR
value: '/charts'
volumes:
- name: charts
hostPath:
path: /data/charts
---
apiVersion: v1
kind: Service
metadata:
name: chartmuseum
namespace: chartmuseum
spec:
selector:
app: chartmuseum
type: ClusterIP
ports:
- port: 8080
targetPort: 8080
wlcom to cusn sds
5、
上传:
curl --data-binary "@wordpress-13.0.23.tgz" http://10.247.186.67:8080/api/charts
curl -L $(kubectl -n chartmuseum get service chartmuseum -o jsonpath='{.spec.clusterIP}:{.spec.ports[].targetPort}')/api/charts | grep "wordpress-13.0.23"
- 点赞
- 收藏
- 关注作者
评论(0)