kubernetes helm試用

9874 ワード

各nodeからhelm tiller docker imageをダウンロード
docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/tiller:v2.2.0 docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/tiller:v2.2.0 gcr.io/kubernetes-helm/tiller:v2.2.0
k 8 s masterでhelmをダウンロード
https://storage.googleapis.com/kubernetes-helm/helm-v2.2.0-linux-amd64.tar.gz tar -xvf helm-v2.2.0-linux-amd64.tar.gz && mv ./linux-amd64/helm/usr/bin/helm
helm初期化
Error:Looks likeなどのコマンドが失敗する可能性があります.https://kubernetes-charts.storage.googleapis.com"is not a valid chart repository or cannot be reached: Get https://kubernetes-charts.storage.googleapis.com/index.yaml:dial tcp 74.125.204.128:443:i/o timeoutは後で再試行できます)
tiller-depoy起動状態kubectl get pods--namespace=kube-system-o wideの表示
helm試用
[root@cloud4ourself-kcluster1 ~]# helm version Client: &version.Version{SemVer:"v2.2.0", GitCommit:"fc315ab59850ddd1b9b4959c89ef008fef5cdf89", GitTreeState:"clean"} Server: &version.Version{SemVer:"v2.2.0", GitCommit:"fc315ab59850ddd1b9b4959c89ef008fef5cdf89", GitTreeState:"clean"}
取得charts
[root@cloud4ourself-kcluster1 ~]# helm search  mysql
NAME            VERSION DESCRIPTION
stable/mysql    0.2.5   Fast, reliable, scalable, and easy to use open-...
stable/mariadb  0.5.10  Fast, reliable, scalable, and easy to use open-...
[root@cloud4ourself-kcluster1 ~]#
[root@cloud4ourself-kcluster1 ~]#
[root@cloud4ourself-kcluster1 ~]# helm install stable/mariadb
NAME:   hazy-heron
LAST DEPLOYED: Wed Mar 15 10:58:20 2017
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Secret
NAME                TYPE    DATA  AGE
hazy-heron-mariadb  Opaque  2     0s

==> v1/ConfigMap
NAME                DATA  AGE
hazy-heron-mariadb  1     0s

==> v1/PersistentVolumeClaim
NAME                STATUS   VOLUME  CAPACITY  ACCESSMODES  AGE
hazy-heron-mariadb  Pending  0s

==> v1/Service
NAME                CLUSTER-IP      EXTERNAL-IP  PORT(S)   AGE
hazy-heron-mariadb  10.100.193.197         3306/TCP  0s

==> extensions/v1beta1/Deployment
NAME                DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
hazy-heron-mariadb  1        1        1           0          0s


NOTES:
MariaDB can be accessed via port 3306 on the following DNS name from within your cluster:
hazy-heron-mariadb.default.svc.cluster.local

To connect to your database:

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

    kubectl run hazy-heron-mariadb-client --rm --tty -i --image bitnami/mariadb --command -- bash

2. Connect using the mysql cli, then provide your password:
    $ mysql -h hazy-heron-mariadb

新規pod kubectl get pod kubectl describe pod hazy-heron-mariadb-239282535-t 501 bの表示
Events:
  FirstSeen LastSeen    Count   From            SubObjectPath   Type        Reason          Message
  --------- --------    -----   ----            -------------   --------    ------          -------
  19m       24s     70  {default-scheduler }            Warning     FailedScheduling    [SchedulerPredicates failed due to PersistentVolumeClaim is not bound: "hazy-heron-mariadb", which is unexpected., SchedulerPredicates failed due to PersistentVolumeClaim is not bound: "hazy-heron-mariadb", which is unexpected., SchedulerPredicates failed due to PersistentVolumeClaim is not bound: "hazy-heron-mariadb", which is unexpected.]

エラーの原因は次のとおりです.
[root@cloud4ourself-kcluster1 ~]# kubectl describe pvc hazy-heron-mariadb
Name:       hazy-heron-mariadb
Namespace:  default
StorageClass:   default
Status:     Pending
Volume:
Labels:     app=hazy-heron-mariadb
        chart=mariadb-0.5.10
        heritage=Tiller
        release=hazy-heron
Capacity:
Access Modes:
Events:
  FirstSeen LastSeen    Count   From                SubObjectPath   Type        Reason          Message
  --------- --------    -----   ----                -------------   --------    ------          -------
  1h        53m     65  {persistentvolume-controller }          Warning     ProvisioningFailed  cannot find volume plugin for alpha provisioning
  52m       52m     2   {persistentvolume-controller }          Warning     ProvisioningFailed  cannot find volume plugin for alpha provisioning
  51m       26m     99  {persistentvolume-controller }          Warning     ProvisioningFailed  cannot find volume plugin for alpha provisioning
  24m       9s      98  {persistentvolume-controller }          Warning     ProvisioningFailed  cannot find volume plugin for alpha provisioning
git clone https://github.com/kubernetes/charts
cd charts/stable/mariadb/templates
grep alpha pvc.yaml
  pvc.yaml:    volume.alpha.kubernetes.io/storage-class: default

[root@cloud4ourself-kcluster1 templates]# kubectl get storageclass
NAME      TYPE
fast      kubernetes.io/rbd
slow      kubernetes.io/rbd

"volume"に変更します.beta.kubernetes.io/storage-class: slow“” helm install stable/mariadb/
[root@cloud4ourself-kcluster1 ~]# kubectl get pvc
NAME                   STATUS    VOLUME                                     CAPACITY   ACCESSMODES   AGE
data-mysql-0           Bound     pvc-6c385d50-057a-11e7-9e49-fa163ef34ac6   10Gi       RWO           4d
data-mysql-1           Bound     pvc-6c3fa1a6-057a-11e7-9e49-fa163ef34ac6   10Gi       RWO           4d
data-mysql-2           Bound     pvc-6c472689-057a-11e7-9e49-fa163ef34ac6   10Gi       RWO           4d
hazy-heron-mariadb     Pending                                                                       5h
saucy-numbat-mariadb   Pending                                                                       6m
[root@cloud4ourself-kcluster1 ~]# kubectl describe pvc saucy-numbat-mariadb
Name:       saucy-numbat-mariadb
Namespace:  default
StorageClass:   slow
Status:     Pending
Volume:
Labels:     app=saucy-numbat-mariadb
        chart=mariadb-0.5.10
        heritage=Tiller
        release=saucy-numbat
Capacity:
Access Modes:
Events:
  FirstSeen LastSeen    Count   From                SubObjectPath   Type        Reason          Message
  --------- --------    -----   ----                -------------   --------    ------          -------
  5m        9s      21  {persistentvolume-controller }          Warning     ProvisioningFailed  Failed to provision volume with StorageClass "slow": rbd: create volume failed, err: executable file not found in $PATH

解決策の参考http://www.jianshu.com/p/98337fc2e8d3
[root@cloud4ourself-kcluster1 ~]# kubectl get pvc
NAME                   STATUS    VOLUME                                     CAPACITY   ACCESSMODES   AGE

hazy-heron-mariadb     Pending                                                                       5h
saucy-numbat-mariadb   Pending                                                                       14m
xrayed-frog-mariadb    Pending                                                                       4m
[root@cloud4ourself-kcluster1 ~]# kubectl get pvc
NAME                   STATUS    VOLUME                                     CAPACITY   ACCESSMODES   AGE

hazy-heron-mariadb     Pending                                                                       5h
saucy-numbat-mariadb   Bound     pvc-1c8320c4-0958-11e7-8870-fa163ef34ac6   8Gi        RWO           14m
xrayed-frog-mariadb    Bound     pvc-86a3a3e6-0959-11e7-8870-fa163ef34ac6   8Gi        RWO           4m

[root@cloud4ourself-kcluster1 ~]# kubectl get pod
NAME                                                              READY     STATUS     RESTARTS   AGE
hazy-heron-mariadb-239282535-t501b                                0/1       Pending    0          5h

saucy-numbat-mariadb-958934623-vg6fk                              0/1       Init:0/1   0          15m

xrayed-frog-mariadb-3843238841-6x4m1                              0/1       Init:0/1   0          5m

[root@cloud4ourself-kcluster1 mariadb]# kubectl get pod
NAME                                                              READY     STATUS    RESTARTS   AGE
hazy-heron-mariadb-239282535-t501b                                0/1       Pending   0          5h

saucy-numbat-mariadb-958934623-vg6fk                              1/1       Running   0          19m

xrayed-frog-mariadb-3843238841-6x4m1                              0/1       Running   0          9m

#########################################
更新2017-08-21
install helm
http://www.jianshu.com/p/1953b86649df
download helm
wget https://storage.googleapis.com/kubernetes-helm/helm-v2.6.0-linux-amd64.tar.gz
tar -xvf helm-v2.6.0-linux-amd64.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/
rm -rf linux-amd64

create sa
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'

run helm
helm init --service-account tiller --tiller-image 4admin2root/tiller:v2.6.0 --upgrade

check tiller in k8s
tiller-deploy-3864618634-gjqn7 1/1 Running 0 8m 10.32.0.60
➜ ~ helm version Client: &version.Version{SemVer:"v2.6.0", GitCommit:"5bc7c619f85d74702e810a8325e0a24f729aa11a", GitTreeState:"clean"} Server: &version.Version{SemVer:"v2.6.0", GitCommit:"5bc7c619f85d74702e810a8325e0a24f729aa11a", GitTreeState:"clean"}
for example:
helm search jenkins
helm install --name my-release --set Persistence.StorageClass=slow stable/jenkins
helm get my-release