目录

摘要:

创建svc.yaml:

创建sts.yaml

孵化命令:


摘要:

由于大量对于sts的稳定性测试和调研, 记录如何快速孵化sts.

目的是作为demo调研使用.

创建svc.yaml:

apiVersion: v1
kind: Service
metadata:
  name: mypod-svc
  labels:
    name: mypod
    app: mypod
spec:
  ports:
  - port: 6379
    name: tcp
  clusterIP: None
  selector:
    app: mypod

创建sts.yaml

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mypod
metadata:
  name: mypod
spec:
  serviceName: mypod-svc
  replicas: 1
  selector:
    matchLabels:
      app: mypod
  template:
    metadata:
      labels:
        app: mypod
        exporter: "mypod-exporter"
    spec:
      containers:
        - name: myfrontend
          image: nginx
          imagePullPolicy: IfNotPresent
          args:
          - /bin/sh
          - -c
          - tail -f /dev/null
          volumeMounts:
          - mountPath: "/data"
            name: mypd
      volumes:
        - name: mypd
          # emptyDir: {}
          hostPath:
            path: /tmp/mypod
            type: DirectoryOrCreate

孵化命令:

kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f ./svc.yaml 

kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f ./sts.yaml 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐