起動
1 2 | $kubectl run mariadb- test -pod --image=mariadb -- env = "MARIADB_ROOT_PASSWORD=secret" pod /mariadb-test-pod created |
1 2 3 | $ kubectl get pods NAME READY STATUS RESTARTS AGE mariadb- test -pod 1 /1 Running 0 2m37s |
1 2 3 4 5 6 | $ +----------------+ | current_user() | +----------------+ | root@localhost | +----------------+ |
1 2 | $ kubectl delete pod mariadb- test -pod pod "mariadb-test-pod" deleted |
Deployment
1 2 | $ mkdir mariadb この中にyamlファイルを作成する |
mariadb/deployment.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | apiVersion: apps/v1 kind: Deployment metadata: name: mariadb-deployment spec: replicas: 2 selector: matchLabels: app: mariadb template: metadata: labels: app: mariadb spec: # specification for pods containers: - name : mariadb image: mariadb ports: - containerPort : 3306 env: - name : MARIADB_ROOT_PASSWORD value: secret |
1 | $ kubectl apply -f mariadb |
1 2 3 4 | ubuntu@master:~$ kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mariadb-deployment-7c89c448bf-qwtgr 1 /1 Running 0 70s 10.1.30.96 worker02 <none> <none> mariadb-deployment-7c89c448bf-twzn5 1 /1 Running 0 70s 10.1.5.32 worker01 <none> <none> |
1 2 3 | $ kubectl exec -it mariadb-deployment-7c89c448bf-qwtgr -- mariadb -uroot -psecret MariaDB [(none)]> |