tjtjtjのメモ

自分のためのメモです

helm リベンジのリベンジ

そういえば前回 nodeport.yaml でselectorテキトーだったような気がした。selector設定しなおしたらできた。

pod のlabel を確認

$ kubectl describe po run
Name:           running-cat-mysql-7fb9cbc74b-nzn6x
Namespace:      default
Priority:       0
Node:           kb22/192.168.0.22
Start Time:     Fri, 16 Aug 2019 19:12:14 +0900
Labels:         app=running-cat-mysql
                pod-template-hash=7fb9cbc74b
Annotations:    cni.projectcalico.org/podIP: 10.244.2.6/32
Status:         Running

nodeport.yaml

apiVersion: v1
kind: Service
metadata:
  name: np
spec:
  selector:
    app: running-cat-mysql
  type: NodePort
  ports:
  - port: 3306
    nodePort: 32306

クラスタ外からmysql接続

$ mysql -h 192.168.0.21 --port=32306 -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 90
Server version: 5.7.14 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)