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
相关推荐
昌sit!5 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
A ?Charis8 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
北漂IT民工_程序员_ZG9 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes
2301_8061313615 小时前
Kubernetes的基本构建块和最小可调度单元pod-0
云原生·容器·kubernetes
SilentCodeY16 小时前
containerd配置私有仓库registry
容器·kubernetes·containerd·镜像·crictl
小安运维日记1 天前
Linux云计算 |【第五阶段】CLOUD-DAY8
linux·运维·docker·云计算·k8s·学习方法
binqian1 天前
【k8s】ClusterIP能http访问,但是不能ping 的原因
http·容器·kubernetes
探索云原生1 天前
GPU 环境搭建指南:如何在裸机、Docker、K8s 等环境中使用 GPU
ai·云原生·kubernetes·go·gpu
是垚不是土1 天前
Istio流量镜像测试
运维·kubernetes·云计算·istio
蚊子不吸吸1 天前
DevOps开发运维简述
linux·运维·ci/cd·oracle·kubernetes·gitlab·devops