Last active
October 3, 2018 10:33
-
-
Save yuuichi-fujioka/dbe08429b63b1ea2b55fa403e756fa62 to your computer and use it in GitHub Desktop.
HelmのChartに少しだけ手を入れたいあなたへ ref: https://qiita.com/yuuichi-fujioka/items/c6899abfb09d60291f2f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app.yaml b/app.yaml | |
index 62f7ee1..672b666 100644 | |
--- a/app.yaml | |
+++ b/app.yaml | |
@@ -7,6 +7,11 @@ environments: | |
k8sVersion: v1.11.0 | |
path: default | |
kind: ksonnet.io/app | |
+libraries: | |
+ rocketchat: | |
+ name: rocketchat | |
+ registry: helm-stable | |
+ version: "" | |
name: rocketchat | |
registries: | |
helm-stable: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree . | |
. | |
├── app.yaml | |
├── components | |
│ └── params.libsonnet | |
├── environments | |
│ ├── base.libsonnet | |
│ └── default | |
│ ├── globals.libsonnet | |
│ ├── main.jsonnet | |
│ └── params.libsonnet | |
├── lib | |
│ └── ksonnet-lib | |
│ └── v1.11.0 | |
│ ├── k.libsonnet | |
│ ├── k8s.libsonnet | |
│ └── swagger.json | |
└── vendor | |
7 directories, 9 files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ brew install ks kubernetes-cli# ksonnetと、kubectlをインストール | |
$ ks version # バージョン確認。ksonnet versionが0.12.0以上でなければならない。 | |
ksonnet version: 0.12.0 | |
jsonnet version: v0.11.2 | |
client-go version: kubernetes-1.10.4 | |
$ # なんとかしてkubernetesのAPIを叩けるようにしておく。~/.kube/configをなんとかしたり | |
$ ks init rocketchat # ksonnetアプリケーションの作成。この時点でKubernetesに接続できる必要あり | |
$ cd rocketchat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local env = std.extVar("__ksonnet/environments"); | |
local params = std.extVar("__ksonnet/params").components["my-app"]; | |
local chart_org = std.prune(std.native("renderHelmChart")( | |
// registry name | |
"helm-stable", | |
// chart name | |
"rocketchat", | |
// chart version | |
params.version, | |
// chart values overrides | |
params.values, | |
// component name | |
params.name, | |
)); | |
[ | |
w + { | |
metadata+: { | |
labels+: { | |
maintainer: "fujioka" | |
}, | |
}, | |
} | |
for w in chart_org | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/components/my-app.jsonnet b/components/my-app.jsonnet | |
index f3eb80e..c8b1532 100644 | |
--- a/components/my-app.jsonnet | |
+++ b/components/my-app.jsonnet | |
@@ -1,7 +1,7 @@ | |
local env = std.extVar("__ksonnet/environments"); | |
local params = std.extVar("__ksonnet/params").components["my-app"]; | |
-std.prune(std.native("renderHelmChart")( | |
+local chart_org = std.prune(std.native("renderHelmChart")( | |
// registry name | |
"helm-stable", | |
// chart name | |
@@ -12,4 +12,15 @@ std.prune(std.native("renderHelmChart")( | |
params.values, | |
// component name | |
params.name, | |
- )) | |
+ )); | |
+ | |
+ [ | |
+ w + { | |
+ metadata+: { | |
+ labels+: { | |
+ maintainer: "fujioka" | |
+ }, | |
+ }, | |
+ } | |
+ for w in chart_org | |
+ ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ks pkg list # Packageの一覧を確認する。 | |
REGISTRY NAME VERSION INSTALLED ENVIRONMENTS | |
======== ==== ======= ========= ============ | |
helm-stable acs-engine-autoscaler 2.2.0 | |
helm-stable aerospike 0.1.7 | |
helm-stable anchore-engine 0.2.0 | |
...(すごく多いので略 | |
helm-stable risk-advisor 2.0.4 | |
helm-stable rocketchat 0.1.3 | |
helm-stable rookout 0.1.0 | |
...(さらに略 | |
incubator redis 40285d8a14f1ac5787e405e1023cf0c07f6aa28c | |
incubator tomcat 40285d8a14f1ac5787e405e1023cf0c07f6aa28c | |
$ | |
$ ks pkg install helm-stable/rocketchat # helm-stableのrocketchatをインストール |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/components/params.libsonnet b/components/params.libsonnet | |
index 34469d7..eccdbad 100644 | |
--- a/components/params.libsonnet | |
+++ b/components/params.libsonnet | |
@@ -6,6 +6,9 @@ | |
"my-app": { | |
name: 'my-rocketchat', | |
values: { | |
+ ingress: { | |
+ enabled: true, | |
+ }, | |
}, | |
version: '0.1.3', | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree . | |
. | |
├── app.yaml | |
(略 | |
└── vendor | |
└── helm-stable | |
└── rocketchat | |
└── helm | |
└── 0.1.3 | |
└── rocketchat # HelmのChartがそのままここに追加されている。 | |
├── Chart.yaml | |
├── charts | |
│ └── mongodb | |
│ ├── Chart.yaml | |
│ ├── README.md | |
│ ├── templates | |
│ │ ├── NOTES.txt | |
│ │ ├── _helpers.tpl | |
│ │ ├── deployment.yaml | |
│ │ ├── pvc.yaml | |
│ │ ├── secrets.yaml | |
│ │ └── svc.yaml | |
│ └── values.yaml | |
├── requirements.lock | |
├── requirements.yaml | |
├── templates | |
│ ├── NOTES.txt | |
│ ├── _helpers.tpl | |
│ ├── deployment.yaml | |
│ ├── ingress.yaml | |
│ ├── pvc.yaml | |
│ ├── secrets.yaml | |
│ └── svc.yaml | |
└── values.yaml | |
16 directories, 29 files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ks prototype list #一覧を確認 | |
NAME DESCRIPTION | |
==== =========== | |
io.ksonnet.pkg.configMap A simple config map with optional user-specified data | |
io.ksonnet.pkg.deployed-service A deployment exposed with a service | |
io.ksonnet.pkg.helm-stable-rocketchat Helm Chart rocketchat from the helm-stable registry | |
io.ksonnet.pkg.namespace Namespace with labels automatically populated from the name | |
io.ksonnet.pkg.single-port-deployment Replicates a container n times, exposes a single port | |
io.ksonnet.pkg.single-port-service Service that exposes a single port | |
$ | |
$ ks generate io.ksonnet.pkg.helm-stable-rocketchat -h # prototypeのパラメータを確認する | |
Usage of prototype-flags: | |
--module string Component module | |
--name string Name of the component | |
--values string Helm values (default "{}") | |
--values-file string Prototype values file (file returns a Jsonnet object) | |
-v, --verbose count[=-1] Increase verbosity. May be given multiple times. | |
--version string Version of the Helm chart. If blank, it will use latest installed version (default "0.1.3") | |
$ ks generate io.ksonnet.pkg.helm-stable-rocketchat my-app --name my-rocketchat # 適用。とりあえずは最低限だけ指定。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree . | |
. | |
├── app.yaml | |
├── components | |
│ ├── my-app.jsonnet | |
│ └── params.libsonnet | |
├── environments | |
│ ├── base.libsonnet | |
(略 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ks registry add helm-stable https://kubernetes-charts.storage.googleapis.com | |
$ ks registry list # helm-stableが追加されている。 | |
NAME OVERRIDE PROTOCOL URI | |
==== ======== ======== === | |
helm-stable helm https://kubernetes-charts.storage.googleapis.com | |
incubator github github.com/ksonnet/parts/tree/master/incubator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ks apply default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ kubectl rollout status deployment my-rocketchat-rocketchat # デプロイが完了するのを待つ | |
$ kubectl port-forward my-rocketchat-rocketchat-68558f8689-hsm7z 8888:3000 # pod名はの後半はランダムなので、自分の環境で出来たものを確認してください。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ks param set my-app values.ingress.enabled true # ingress.enabledにtrueを設定する | |
$ ks param list # 確認 | |
COMPONENT PARAM VALUE | |
========= ===== ===== | |
my-app name 'my-rocketchat' | |
my-app values { ingress: { | |
enabled: true, | |
} } | |
my-app version '0.1.3' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ kubectl get deployment -o=custom-columns=NAME:.metadata.name,MAINTAINER:.metadata.labels.maintainer | |
NAME MAINTAINER | |
my-rocketchat-mongodb fujioka | |
my-rocketchat-rocketchat fujioka |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment