k8s kubectl 常用yaml

存储挂载pvc

yaml 复制代码
apiVersion: v1
kind: Pod
metadata:
  name: hw-mount
  namespace: cnoc-hw-storage
  #namespace: project-10321
spec:
 # nodeSelector:
 # csi.storage.k8s.io/lvm: "true"
 # nodeName: 10-10-10-10.hw
 # schedulerName: lvm-scheduler
  containers:
  - name: busybox
    #image: docker.io/library/busybox:latest
    image: ikubernetes/myapp:v1
    resources:
      limits:
        cpu: "1"
        memory: 1000Mi
      requests:
        cpu: 100m
        memory: 300Mi
    volumeMounts:
    - name: mount
      mountPath: /hw
  volumes:
  - name: mount
    persistentVolumeClaim:
      claimName: cnoc-pvc-1

查看挂载

bash 复制代码
kubectl exec -it hw-mount -n cnoc-hw-storage -- sh

df -h

cronjob

bash 复制代码
cat>hw-cronjob.yaml<<'EOF'
apiVersion: batch/v1
kind: CronJob
metadata:
  creationTimestamp: null
  #name: hw-cronjob
  namespace: project-1
  namespace: cnoc-hwdev
spec:
  jobTemplate:
    metadata:
      creationTimestamp: null
      name: hw-cronjob
    spec:
      template:
        metadata:
          creationTimestamp: null
        spec:
          containers:
          - image: dev.registry:18083/hhhwww/service-14756:117041
            name: hw-cronjob
            resources: {}
          restartPolicy: OnFailure
  schedule: '*/1 * * * *'
status: {}
EOF

查看

bash 复制代码
kubectl api-resources | grep job

kubectl get job -A

kubectl apply -f hw-cronjob.yaml

kubectl delete -f hw-cronjob.yaml

daemonset

bash 复制代码
cat>hw-daemonset.yaml<<'EOF'
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: nginx
  name: hw-daemonset
  namespace: project-3556
spec:
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: dev.registry:18083/hhhwww/earth/service-14756:117041
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
      terminationGracePeriodSeconds: 30
EOF

查看

bash 复制代码
kubectl get daemonset -A
相关推荐
别骂我h2 小时前
Kubernetes服务发布基础
云原生·容器·kubernetes
weixin_399380693 小时前
k8s一键部署tongweb企业版7049m6(by why+lqw)
java·linux·运维·服务器·云原生·容器·kubernetes
lovely_nn18 小时前
docker 介绍
docker·k8s
斯普信专业组20 小时前
K8s环境下基于Nginx WebDAV与TLS/SSL的文件上传下载部署指南
nginx·kubernetes·ssl
&如歌的行板&21 小时前
如何在postman中动态请求k8s中的pod ip(基于nacos)
云原生·容器·kubernetes
云妙算1 天前
K8s 弹性伸缩踩坑实录:周末 2 天烧掉 10 万元!?
云原生·kubernetes
退役小学生呀10 天前
三、kubectl使用详解
云原生·容器·kubernetes·k8s
程序员小潘11 天前
Kubernetes多容器Pod实战
云原生·容器·kubernetes
ALe要立志成为web糕手11 天前
Kubernetes安全
安全·web安全·网络安全·k8s·云安全