新しいミドルウェアを触ってみたい場合、まず実際に動かしてみたいと思うことが多いけど、minikubeはそれを実現するツールとして便利そうだった。 今回はそれをさらに進めて、helmを使ってみる。
いま仕事で使っているconcourseで試してみた。
まず前回の分を消してから
ᐅ minikube delete
再度新規作成する。
ᐅ minikube start Starting local Kubernetes v1.9.0 cluster... Starting VM... Getting VM IP address... Moving files into cluster... Setting up certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... Kubectl is now configured to use the cluster. Loading cached images from config file.
helmを初期化する。これによってtillerというpodがkube-system ネームスペースの中に作成される。これがk8sクラスタ内でhelmを管理しているみたい。
ᐅ helm init $HELM_HOME has been configured at /Users/xxx/.helm. Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster. Happy Helming!
helmの個々のパッケージのことをchartというが、
Charts are packages of pre-configured Kubernetes resources.
chartはk8sのリソースをまとめてパッケージ化して、これをinstallすることで、あるパッケージをそのまま利用可能にするための1つのまとまり、みたいなイメージでよさそう。
concourseのhelm chartは公式にある。
公式によると
helm install stable/concourse
これだけで実行できそうだが、実際にMacのminikube上でやると失敗する。
ᐅ helm install --name concourse stable/concourse Error: release concourse failed: clusterroles.rbac.authorization.k8s.io "concourse-web" is forbidden: attempt to grant extra privileges: [PolicyRule{Resources:["secrets"], APIGroups:[""], Verbs:["get"]}] user=&{system:serviceaccount:kube-system:default 788772bb-27fb-11e8-96cb-0800274e6818 [system:serviceaccounts system:serviceaccounts:kube-system system:authenticated] map[]} ownerrules=[] ruleResolutionErrors=[]
RBACの関係でうまくいかないらしい。
RBACとは https://kubernetes.io/docs/admin/authorization/#rbac-mode このへんなのだろうが、ひとまずアクセス権限周りは使わずに試したいので、values.ymlを編集して起動する。
https://github.com/kubernetes/charts/blob/master/stable/concourse/values.yaml#L506
このファイルを落としてきて、rbacをenableにしているこの行をfalseにする。
これで起動する。
ᐅ helm install --name concourse -f values.yaml stable/concourse NAME: concourse LAST DEPLOYED: Thu Mar 15 12:58:16 2018 NAMESPACE: default STATUS: DEPLOYED RESOURCES: ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE concourse-postgresql ClusterIP 10.106.7.53 <none> 5432/TCP 0s concourse-web ClusterIP 10.97.28.26 <none> 8080/TCP,2222/TCP 0s concourse-worker ClusterIP None <none> <none> 0s ==> v1beta1/Deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE concourse-postgresql 1 1 1 0 0s concourse-web 1 1 1 0 0s ==> v1beta1/StatefulSet NAME DESIRED CURRENT AGE concourse-worker 2 2 0s ==> v1beta1/PodDisruptionBudget NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE concourse-worker 1 N/A 0 0s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE concourse-postgresql-664df7c4cc-4nzc8 0/1 ContainerCreating 0 0s concourse-web-7f45c95c94-zthqq 0/1 ContainerCreating 0 0s concourse-worker-0 0/1 ContainerCreating 0 0s concourse-worker-1 0/1 ContainerCreating 0 0s ==> v1/Namespace NAME STATUS AGE concourse-main Active 0s ==> v1/Secret NAME TYPE DATA AGE concourse-postgresql Opaque 1 0s concourse-concourse Opaque 7 0s ==> v1/PersistentVolumeClaim NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE concourse-postgresql Bound pvc-172f7f10-2805-11e8-96cb-0800274e6818 8Gi RWO standard 0s NOTES: * Concourse can be accessed: * Within your cluster, at the following DNS name at port 8080: concourse-web.default.svc.cluster.local * From outside the cluster, run these commands in the same shell: export POD_NAME=$(kubectl get pods --namespace default -l "app=concourse-web" -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use Concourse" kubectl port-forward --namespace default $POD_NAME 8080:8080 * Login with the following credentials Username: concourse Password: concourse * If this is your first time using Concourse, follow the tutorial at https://concourse.ci/hello-world.html ******************* ******WARNING****** ******************* You are using the "naive" baggage claim driver, which is also the default value for this chart. This is the default for compatability reasons, but is very space inefficient, and should be changed to either "btrfs" (recommended) or "overlay" depending on that filesystem's support in the Linux kernel your cluster is using. Please see https://github.com/concourse/concourse/issues/1230 and https://github.com/concourse/concourse/issues/1966 for background.
podの存在を確認。
ᐅ kubectl get pods NAME READY STATUS RESTARTS AGE concourse-postgresql-664df7c4cc-4nzc8 1/1 Running 0 46s concourse-web-7f45c95c94-zthqq 0/1 ContainerCreating 0 46s concourse-worker-0 0/1 ContainerCreating 0 46s concourse-worker-1 1/1 Running 0 46s
port-forwardでつないでみる。
ᐅ export POD_NAME=$(kubectl get pods --namespace default -l "app=concourse-web" -o jsonpath="{.items[0].metadata.name}") ᐅ kubectl port-forward --namespace default $POD_NAME 8080:8080 Forwarding from 127.0.0.1:8080 -> 8080 Handling connection for 8080 Handling connection for 8080 Handling connection for 8080 Handling connection for 8080
http://localhost:8080にアクセス。 デフォルトのID/Passはvalues.yamlのにも書いてあったが、concourse/concourseでログインできる。
この後はflyコマンドを使って実際にパイプラインを作ってみる。