k8s记录

拉取镜像部署服务

拉镜像:
docker pull alpha-harbor.51iwifi.com/video-cloud/dataservice-node-provider:1.0.2.55
编排文件:
启动容器:
helm install -n front-gateway ./front-gateway
其中-n为指定namespace,可以选择没有,./front-gateway指的是该服务的编排文件

创建PVC

创建一个固定的文件目录作为存储pvc配置文件,新建yaml文件,内容如下:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: analysis-push
  namespace: beta
  annotations:
    volume.beta.kubernetes.io/storage-class: "default"
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi

这里修改的就是name,namespace,创建完后启动PVC:helm apply -f analysis-push.yaml
至此启动完毕后,在编排文件中调用该PVC,一般是在deployment.yaml文件中

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "fullname" . }}
  labels:
    app: {{ template "name" . }}
    chart: {{ template "chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "name" . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: jar
          image: "{{ .Values.image.war.repository }}:{{ .Values.image.war.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env:
            - name: TZ
              value: Asia/Shanghai
          volumeMounts:
          - mountPath: /service/media/storage
            name: app-volume
      volumes:
      - name: app-volume
        persistentVolumeClaim:
          claimName: smart-home-manage

claimName为刚启动的PVC名称,mountPath为pod内部挂载出的目录

批量删除服务

helm list |grep opf-datas|awk '{printf ""$1" "}' | xargs helm delete --purge

你可能感兴趣的:(学习笔记)