2018年8月1日 | Leave a comment 问题 解决: --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql-keycloak-pvc-dev spec: storageClassName: cbs accessModes: - ReadWriteOnce resources: requests: storage: 10Gi --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: mysql-keycloak-deploy-dev spec: replicas: 1 template: metadata: labels: app: mysql-keycloak-dev spec: containers: - name: mysql-keycloak-dev image: mysql:5.7 args: - "--datadir=/var/lib/mysql/d1" #pv默认的目录有东西 ports: - containerPort: 3306 volumeMounts: - name: mysql-data mountPath: /var/lib/mysql env: - name: MYSQL_ROOT_PASSWORD value: 123456 - name: MYSQL_DATABASE value: keycloak volumes: - name: mysql-data persistentVolumeClaim: claimName: mysql-keycloak-pvc-dev --- apiVersion: v1 kind: Service metadata: name: mysql-keycloak-service-dev spec: selector: app: mysql-keycloak-dev ports: - name: tcp3306 protocol: TCP port: 3306 targetPort: 3306 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 ---apiVersion: v1kind: PersistentVolumeClaimmetadata: name: mysql-keycloak-pvc-devspec: storageClassName: cbs accessModes: - ReadWriteOnce resources: requests: storage: 10Gi---apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: mysql-keycloak-deploy-devspec: replicas: 1 template: metadata: labels: app: mysql-keycloak-dev spec: containers: - name: mysql-keycloak-dev image: mysql:5.7 args: - "--datadir=/var/lib/mysql/d1" #pv默认的目录有东西 ports: - containerPort: 3306 volumeMounts: - name: mysql-data mountPath: /var/lib/mysql env: - name: MYSQL_ROOT_PASSWORD value: 123456 - name: MYSQL_DATABASE value: keycloak volumes: - name: mysql-data persistentVolumeClaim: claimName: mysql-keycloak-pvc-dev---apiVersion: v1kind: Servicemetadata: name: mysql-keycloak-service-devspec: selector: app: mysql-keycloak-dev ports: - name: tcp3306 protocol: TCP port: 3306 targetPort: 3306