k8s kubectl 常用yaml

存储挂载pvc

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

查看挂载

kubectl exec -it hw-mount -n cnoc-hw-storage -- sh

df -h

cronjob

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

查看

kubectl api-resources | grep job

kubectl get job -A

kubectl apply -f hw-cronjob.yaml

kubectl delete -f hw-cronjob.yaml

daemonset


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

查看

kubectl get daemonset -A

相关推荐

  1. k8s kubectl yaml

    2024-05-09 16:22:02       33 阅读
  2. K8S 命令

    2024-05-09 16:22:02       55 阅读
  3. K8s命令

    2024-05-09 16:22:02       60 阅读
  4. K8S命令

    2024-05-09 16:22:02       54 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-09 16:22:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-09 16:22:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-05-09 16:22:02       82 阅读
  4. Python语言-面向对象

    2024-05-09 16:22:02       91 阅读

热门阅读

  1. 计算机视觉

    2024-05-09 16:22:02       31 阅读
  2. SQL注入(数据库基础)

    2024-05-09 16:22:02       43 阅读
  3. 什么是BFF API

    2024-05-09 16:22:02       28 阅读
  4. 2024-05-08 postgres-调试及分析-记录

    2024-05-09 16:22:02       30 阅读
  5. 接口防抖(重复点击)

    2024-05-09 16:22:02       29 阅读
  6. c++ 刷题代码加速

    2024-05-09 16:22:02       28 阅读
  7. 理解 HTTP Multipart:入门介绍

    2024-05-09 16:22:02       36 阅读
  8. VS2022Qt6通过ODBC连接MySQL

    2024-05-09 16:22:02       32 阅读
  9. Clickhouse中物化视图和位图和索引的用法

    2024-05-09 16:22:02       33 阅读