helm 命令行替代变量部署应用

定义变量或许有点繁琐,可以直接使用命令行--set 参数替代变量,进行部署应用!

 

[root@node-16 nfs-client]# helm install mysql-02 --set persistence.storageClass="managed-nfs-storage" stable/mysql

NAME: mysql-02

LAST DEPLOYED: Tue Apr 28 13:33:06 2020

NAMESPACE: default

STATUS: deployed

REVISION: 1

NOTES:

MySQL can be accessed via port 3306 on the following DNS name from within your cluster:

mysql-02.default.svc.cluster.local

To get your root password run:

    MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default mysql-02 -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo)

To connect to your database:

1. Run an Ubuntu pod that you can use as a client:

    kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il

2. Install the mysql client:

    $ apt-get update && apt-get install mysql-client -y

3. Connect using the mysql cli, then provide your password:

    $ mysql -h mysql-02 -p

To connect to your database directly from outside the K8s cluster:

    MYSQL_HOST=127.0.0.1

    MYSQL_PORT=3306

    # Execute the following command to route the connection:

    kubectl port-forward svc/mysql-02 3306

    mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}

[root@node-16 nfs-client]#

[root@node-16 nfs-client]#

[root@node-16 nfs-client]# helm list

NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION

db01            default         1               2020-04-26 13:56:58.07831662 +0800 CST  deployed        mysql-1.6.3     5.7.28    

mysql           default         1               2020-04-28 13:13:23.036473313 +0800 CST deployed        mysql-1.6.3     5.7.28    

mysql-02        default         1               2020-04-28 13:33:06.455685197 +0800 CST deployed        mysql-1.6.3     5.7.28    

[root@node-16 nfs-client]#

[root@node-16 nfs-client]# kubectl get pv

NAME      CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM        STORAGECLASS          REASON   AGE

pvc-dfe1b79c-e36a-4fef-aa11-3263c4e23ecb   8Gi  RWO    Delete    Bound    default/mysql-02                           managed-nfs-storage            68s

[root@node-16 nfs-client]#

[root@node-16 nfs-client]# kubectl get pvc

NAME           STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS          AGE

mysql-02       Bound    pvc-dfe1b79c-e36a-4fef-aa11-3263c4e23ecb   8Gi        RWO            managed-nfs-storage   2m5s

 

[root@node-16 nfs-client]#

[root@node-16 nfs-client]#

[root@node-16 nfs-client]# kubectl get pod

NAME                                      READY   STATUS    RESTARTS   AGE

db01-mysql-6ff46d6ccb-6whjz               1/1     Running   0          47h

metrics-app-7674cfb699-5mbxm              1/1     Running   2          4d3h

metrics-app-7674cfb699-ttdgz              1/1     Running   1          2d17h

mysql-02-bcbc46d87-nc2db                  1/1     Running   0          2m31s

 

直接登录pod 检查mysql

[root@node-16 nfs-client]# kubectl exec mysql-02-bcbc46d87-nc2db -it /bin/bash
root@mysql-02-bcbc46d87-nc2db:/# 
root@mysql-02-bcbc46d87-nc2db:/#              
root@mysql-02-bcbc46d87-nc2db:/# 
root@mysql-02-bcbc46d87-nc2db:/# mysql -uroot -pF23XVArMGV
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 88
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值