9
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacにHelmをインストールする

Posted at

はじめに

  • Mac で Helmを使えるようにします
  • 環境
    • server: GKE v1.10.9-gke.5
    • client: macOS Mojave 10.14

参考: Installing Helm

手順

MacにHelmのコマンドラインツールをインストール

$ brew install kubernetes-helm
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
esptool                      hexyl                        libnova                      moarvm                       nqp                          rakudo                       switch-lan-play
==> Updated Formulae
libidn2 ✔                    django-completion            fselect                      kitchen-sync                 mkcert                       podofo                       sqlmap
vim ✔                        dlib                         geeqie                       less                         mkvtoolnix                   primesieve                   swiftlint
wget ✔                       dovecot                      gexiv2                       libetpan                     mozjpeg                      r                            tcc
akamai                       druid                        git-quick-stats              libgxps                      mutt                         rabbitmq                     tor
apache-drill                 ed                           gmic                         libmicrohttpd                nativefier                   rebar3                       vegeta
azure-cli                    emacs-clang-complete-async   gmt                          libpsl                       neovim                       recutils                     vips
bash                         eslint                       golang-migrate               libsamplerate                openconnect                  restic                       visp
boost                        exiv2                        isync                        libsodium                    opencv                       scalapack                    whois
citus                        fauna-shell                  jabba                        lsdvd                        php-cs-fixer                 siril                        wp-cli-completion
clang-format                 fonttools                    jenkins                      mercurial                    picard-tools                 sox
==> Deleted Formulae
cctools                                            cctools-headers                                    ld64                                               php@5.6

==> Downloading https://homebrew.bintray.com/bottles/kubernetes-helm-2.12.1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring kubernetes-helm-2.12.1.mojave.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/kubernetes-helm/2.12.1: 51 files, 79.4MB
  • version確認 (パスを通すため、bashは再ログイン)
$ helm version
Client: &version.Version{SemVer:"v2.12.1", GitCommit:"02a47c7249b1fc6d8fd3b94e6b4babf9d818144e", GitTreeState:"clean"}
Error: could not find tiller
~

could not find tiller と出てますね。 Kubernetesのクラスタ側にもインストールします

GKE側にHelmをインストール

  • kubectlは実行できるようにしておきます。
$ kubectl cluster-info
Kubernetes master is running at https://xx.xx.xx.xx
GLBCDefaultBackend is running at https://xx.xx.xx.xx/api/v1/namespaces/kube-system/services/default-http-backend:http/proxy
Heapster is running at https://xx.xx.xx.xx/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at https://xx.xx.xx.xx/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://xx.xx.xx.xx/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
  • kube-systemで動いているPodの一覧。 あとでみるので、先に見ておきます。
~ ❯❯❯ kubectl get pods --namespace kube-system
NAME                                                     READY     STATUS    RESTARTS   AGE
event-exporter-v0.2.3-54f94754f4-rfnt7                   2/2       Running   0          3d
fluentd-gcp-scaler-6d7bbc67c5-j62sh                      1/1       Running   0          3d
fluentd-gcp-v3.1.0-4krp8                                 2/2       Running   0          3d
fluentd-gcp-v3.1.0-6m2tt                                 2/2       Running   0          3d
heapster-v1.5.3-8c5d877c7-vwt24                          3/3       Running   0          3d
kube-dns-788979dc8f-7bjfh                                4/4       Running   0          3d
kube-dns-788979dc8f-8v9jr                                4/4       Running   0          3d
kube-dns-autoscaler-79b4b844b9-96vrw                     1/1       Running   0          3d
kube-proxy-gke-kube-cluster-default-pool-50840a17-7cfv   1/1       Running   0          3d
kube-proxy-gke-kube-cluster-default-pool-50840a17-d9h1   1/1       Running   0          3d
l7-default-backend-5d5b9874d5-cjdr5                      1/1       Running   0          3d
metrics-server-v0.2.1-7486f5bd67-lbgnl                   2/2       Running   0          3d
~
  • Tillerをインストール
$ helm init
Creating /Users/user/.helm
Creating /Users/user/.helm/repository
Creating /Users/user/.helm/repository/cache
Creating /Users/user/.helm/repository/local
Creating /Users/user/.helm/plugins
Creating /Users/user/.helm/starters
Creating /Users/user/.helm/cache/archive
Creating /Users/user/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /Users/user/.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.

Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!
~

おお、おわった。そして、kube-systemには、、

~ ❯❯❯ kubectl get pods --namespace kube-system

NAME                                                     READY     STATUS    RESTARTS   AGE
(..省略..)
tiller-deploy-5b6b7d479c-67f9q                           1/1       Running   0          56s

いました! tiller!

試しに mongodb でも立てて見る

~ ❯❯❯ helm repo update                                                                          ✘ 1
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈
~ ❯❯❯
~ ❯❯❯
~ ❯❯❯ helm install stable/mongodb
Error: no available release name found
~

。。と思ったら、 エラーが発生

同じ状況の方がいらっしゃったので、参考にさせていただきました。
以下を実行したあとだと成功します。

k8s helmで Error: no available release name found になったとき

k8sの ユーザ 権限周りがまださっぱりわからない。。。これからちゃんと勉強します。

$ 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"}}}}'
~ ❯❯❯ helm install stable/mongodb
NAME:   flabby-puma
LAST DEPLOYED: Tue Jan  8 23:20:24 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Service
NAME                 TYPE       CLUSTER-IP     EXTERNAL-IP  PORT(S)    AGE
flabby-puma-mongodb  ClusterIP  10.15.254.242  <none>       27017/TCP  1s

==> v1beta1/Deployment
NAME                 DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
flabby-puma-mongodb  1        1        1           0          1s

==> v1/Pod(related)
NAME                                  READY  STATUS   RESTARTS  AGE
flabby-puma-mongodb-657f46c8b5-6gxbc  0/1    Pending  0         1s

==> v1/Secret
NAME                 TYPE    DATA  AGE
flabby-puma-mongodb  Opaque  1     1s

==> v1/PersistentVolumeClaim
NAME                 STATUS   VOLUME    CAPACITY  ACCESS MODES  STORAGECLASS  AGE
flabby-puma-mongodb  Pending  standard  1s


NOTES:


** Please be patient while the chart is being deployed **

MongoDB can be accessed via port 27017 on the following DNS name from within your cluster:

    flabby-puma-mongodb.default.svc.cluster.local

To get the root password run:

    export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace default flabby-puma-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)

To connect to your database run the following command:

    kubectl run --namespace default flabby-puma-mongodb-client --rm --tty -i --restart='Never' --image bitnami/mongodb --command -- mongo admin --host flabby-puma-mongodb --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/flabby-puma-mongodb 27017:27017 &
    mongo --host 127.0.0.1 --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD

できました!

  • kubectl
~ ❯❯❯ kubectl get pods
NAME                                   READY     STATUS    RESTARTS   AGE
flabby-puma-mongodb-657f46c8b5-6gxbc   1/1       Running   0          2m

とりあえず動いているようなので、今回はここまでにします

9
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?