環境
- Windows10 Pro
- minikube
helmとは
- k8s用のパッケージマネージャー Linuxでyumとかにあたるもの
- kubectlコマンドでymalファイルを使う場合、そのyamlファイルを作ってあげないといけない。それらの置き場所がインターネット上のリポジトリにあり、そこを参照してダウンロード、デプロイまでしてくれる
手順
準備
mkdir C:\tools\helm\
Invoke-WebRequest -Uri https://storage.googleapis.com/kubernetes-helm/helm-v2.13.0-windows-amd64.zip -OutFile C:\tools\helm\helm-v2.13.0-windows-amd64.zip
cd C:\tools\helm\
Expand-Archive -Path C:\tools\helm\helm-v2.13.0-windows-amd64.zip
move .\helm-v2.13.0-windows-amd64\windows-amd64\helm.exe .
環境変数設定
初期設定
helm init
インストール確認
helm version
サンプルアプリケーションをデプロイする
クラスタロールを作成する
Tillerを使うために必要で、helmコマンド実行時に動作するPod。
helmでデプロイされるPodたちを管理するPod的なイメージだと思う
clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
labels:
kubernetes.io/bootstrapping: rbac-defaults
name: cluster-admin
rules:
- apiGroups:
- '*'
resources:
- '*'
verbs:
- '*'
- nonResourceURLs:
- '*'
verbs:
- '*'
クラスタロールをデプロイ
kubectl create -f .\cluserrole.yaml
.\kubectl.exe create serviceaccount -n kube-system tiller
.\kubectl.exe create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller
デプロイされているか確認
.\kubectl.exe --namespace kube-system get pods
Redisをインストール
helm install stable/redis --set serviceType=NodePort
デプロイされているか確認
PS C:\Users\yuta> .\kubectl.exe get pod
NAME READY STATUS RESTARTS AGE
linting-sparrow-redis-master-0 1/1 Running 0 88s
linting-sparrow-redis-slave-0 1/1 Running 0 88s
linting-sparrow-redis-slave-1 1/1 Running 0 32s
PS C:\Users\yuta>