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
相关推荐
敲上瘾1 天前
【探索实战】:Kurator分布式统一应用分发平台的全面解析与实践指南
分布式·容器·kubernetes·serverless
Connie14511 天前
记一次K8s故障告警排查(Grafna告警排查)
云原生·容器·kubernetes·grafana
谷隐凡二2 天前
Kubernetes主从架构简单解析:基于Python的模拟实现
python·架构·kubernetes
陈陈CHENCHEN2 天前
SuperMap iManager for K8s 离线环境镜像仓库 Containerd 部署
kubernetes
会飞的小蛮猪2 天前
Ubuntu24.04 基于Containerd部署K8s1.34(私服部署)
docker·云原生·kubernetes
间彧2 天前
Kubernetes滚动发布详解
kubernetes
间彧2 天前
在实际生产环境中,Kubernetes声明式API如何实现蓝绿部署、金丝雀发布等高级部署策略?
kubernetes
间彧2 天前
Kubernetes声明式API相比传统命令式API在故障恢复场景下的具体优势有哪些?
kubernetes·github
间彧2 天前
为什么说Kubernetes的API设计是其成功的关键因素之一?
kubernetes
间彧2 天前
Kubernetes Deployment 配置简化实战:从复杂到高效
kubernetes