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
相关推荐
wuxingge9 小时前
k8s1.30.0高可用集群部署
云原生·容器·kubernetes
志凌海纳SmartX10 小时前
趋势洞察|AI 能否带动裸金属 K8s 强势崛起?
云原生·容器·kubernetes
锅总10 小时前
nacos与k8s service健康检查详解
云原生·容器·kubernetes
BUG弄潮儿10 小时前
k8s 集群安装
云原生·容器·kubernetes
颜淡慕潇12 小时前
【K8S系列】kubectl describe pod显示ImagePullBackOff,如何进一步排查?
后端·云原生·容器·kubernetes
Linux运维日记12 小时前
k8s1.31版本最新版本集群使用容器镜像仓库Harbor
linux·docker·云原生·容器·kubernetes
一名路过的小码农14 小时前
ceph 18.2.4二次开发,docker镜像制作
ceph·docker·容器
AI_小站14 小时前
RAG 示例:使用 langchain、Redis、llama.cpp 构建一个 kubernetes 知识库问答
人工智能·程序人生·langchain·kubernetes·llama·知识库·rag
长囧鹿18 小时前
云原生之k8s服务管理
云原生·容器·kubernetes
怡雪~18 小时前
centos7.9搭建k8s集群
云原生·容器·kubernetes