前提

1、在ACK控制台切换到所要操作的集群
选中命名空间–>存储–>存储声明–>创建
阿里云ACK配置OSS类型存储卷-LMLPHP
2、创建存储声明
阿里云ACK配置OSS类型存储卷-LMLPHP
阿里云ACK配置OSS类型存储卷-LMLPHP

点击创建后会出现如下新建的声明、存储卷以及oss-key
阿里云ACK配置OSS类型存储卷-LMLPHP
存储卷
阿里云ACK配置OSS类型存储卷-LMLPHP
oss key
阿里云ACK配置OSS类型存储卷-LMLPHP
3、应用

          volumeMounts:
            - mountPath: /data/logs/tomcat-web/
              name: volume-f7zn4
              subPath: tomcat-web/
          workingDir: /usr/local/tomcat/
      volumes:
        - name: volume-f7zn4
          persistentVolumeClaim:
            claimName: test-oss-index

4、各自独自创建yaml文件
1)oss
其中oss id和oss key都需要先进行 base64 编码

apiVersion: v1
data:
  akId: TFRBSTV0Q3JtUHBVVEMza2FD8KWONKGE
  akSecret: GJIEKSJ5KSKXeGVJZ3FWano0WkhUQTRVNlRQbjM0
kind: Secret
metadata:
  managedFields:
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:data':
          .: {}
          'f:akId': {}
          'f:akSecret': {}
        'f:type': {}
      manager: ACK-Console Apache-HttpClient
      operation: Update
  name: oss-key
  namespace: test
type: Opaque

2)存储声明

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    pv.kubernetes.io/bind-completed: 'yes'
    pv.kubernetes.io/bound-by-controller: 'yes'
  finalizers:
    - kubernetes.io/pvc-protection
  managedFields:
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:spec':
          'f:accessModes': {}
          'f:resources':
            'f:requests':
              .: {}
              'f:storage': {}
          'f:selector': {}
          'f:storageClassName': {}
          'f:volumeMode': {}
      manager: ACK-Console Apache-HttpClient
      operation: Update
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            .: {}
            'f:pv.kubernetes.io/bind-completed': {}
            'f:pv.kubernetes.io/bound-by-controller': {}
        'f:spec':
          'f:volumeName': {}
      manager: kube-controller-manager
      operation: Update
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:status':
          'f:accessModes': {}
          'f:capacity':
            .: {}
            'f:storage': {}
          'f:phase': {}
      manager: kube-controller-manager
      operation: Update
      subresource: status
  name: test-oss-index
  namespace: test
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 200Gi
  selector:
    matchLabels:
      alicloud-pvname: test-pvc-test-oss-index
  storageClassName: oss
  volumeMode: Filesystem
  volumeName: test-pvc-test-oss-index
status:
  accessModes:
    - ReadWriteMany
  capacity:
    storage: 200Gi
  phase: Bound

3)存储卷

apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    pv.kubernetes.io/bound-by-controller: 'yes'
  finalizers:
    - kubernetes.io/pv-protection
  labels:
    alicloud-pvname: test-pvc-test-oss-index
  managedFields:
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:labels':
            .: {}
            'f:alicloud-pvname': {}
        'f:spec':
          'f:accessModes': {}
          'f:capacity':
            .: {}
            'f:storage': {}
          'f:csi':
            .: {}
            'f:driver': {}
            'f:nodePublishSecretRef': {}
            'f:volumeAttributes':
              .: {}
              'f:bucket': {}
              'f:otherOpts': {}
              'f:path': {}
              'f:url': {}
            'f:volumeHandle': {}
          'f:persistentVolumeReclaimPolicy': {}
          'f:storageClassName': {}
          'f:volumeMode': {}
      manager: ACK-Console Apache-HttpClient
      operation: Update
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            .: {}
            'f:pv.kubernetes.io/bound-by-controller': {}
        'f:spec':
          'f:claimRef':
            .: {}
            'f:apiVersion': {}
            'f:kind': {}
            'f:name': {}
            'f:namespace': {}
            'f:resourceVersion': {}
            'f:uid': {}
      manager: kube-controller-manager
      operation: Update
    - apiVersion: v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:status':
          'f:phase': {}
      manager: kube-controller-manager
      operation: Update
      subresource: status
  name: test-pvc-test-oss-index
spec:
  accessModes:
    - ReadWriteMany
  capacity:
    storage: 200Gi
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: test-oss-index
    namespace: test
  csi:
    driver: ossplugin.csi.alibabacloud.com
    nodePublishSecretRef:
      name: oss-key
      namespace: test
    volumeAttributes:
      bucket: api-pass
      otherOpts: ''
      path: /
      url: oss-cn-hongkong-internal.aliyuncs.com
    volumeHandle: test-pvc-test-oss-index
  persistentVolumeReclaimPolicy: Retain
  storageClassName: oss
  volumeMode: Filesystem
status:
  phase: Bound
05-14 15:21