mariaDB

【MicroK8s】

とりあえず動かしてみる

$kubectl run mariadb-test-pod --image=mariadb --env="MARIADB_ROOT_PASSWORD=secret"
pod/mariadb-test-pod created
$ kubectl get pods
NAME               READY   STATUS    RESTARTS   AGE
mariadb-test-pod   1/1     Running   0          2m37s
$ 
+----------------+
| current_user() |
+----------------+
| root@localhost |
+----------------+
$ kubectl delete pod mariadb-test-pod
pod "mariadb-test-pod" deleted

Deployment

$ mkdir mariadb
この中にyamlファイルを作成する

mariadb/deployment.yaml

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
$ kubectl apply -f mariadb
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>
$ kubectl exec -it mariadb-deployment-7c89c448bf-qwtgr -- mariadb -uroot -psecret

MariaDB [(none)]> 
タイトルとURLをコピーしました