使用kubeadm搭建好kubernetes集群后就可以动手部署自己的应用了。
本文用例来自官网,如有需要请参看 kubernetes官网
kubernetes 1.13.1
docker 18.06.1-ce
mysql 5.7
kind: PersistentVolumeapiVersion: v1metadata: name: mysql-pv-volume labels: type: localspec: storageClassName: manual capacity: storage: 5Gi accessModes: - ReadWriteOnce hostPath: path: "/mnt/data"---apiVersion: v1kind: PersistentVolumeClaimmetadata: name: mysql-pv-claimspec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 2Gi
apiVersion: v1kind: Servicemetadata: name: mysqlspec: ports: - port: 3306 selector: app: mysql clusterIP: None---apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2kind: Deploymentmetadata: name: mysqlspec: selector: matchLabels: app: mysql strategy: type: Recreate template: metadata: labels: app: mysql spec: containers: - image: mysql:5.7 name: mysql env: # Use secret in real usage - name: MYSQL_ROOT_PASSWORD value: uwaynemya ports: - containerPort: 3306 name: mysql volumeMounts: - name: mysql-persistent-storage mountPath: /var/lib/mysql volumes: - name: mysql-persistent-storage persistentVolumeClaim: claimName: mysql-pv-claim
上述代码均可以在 haoprogrammer github 上找到
如果对您有帮助希望可以帮忙点颗星,感谢。
您的支持是我最大的动力!