kube: standardize on a `local ns` convention
A convention is introduced to specify the kube.Namespace object in a deployment as a `local ns` instead of an `ns:` or a `namespace:` for these reasons:
- non-cluster admins cannot create new namespaces, and we've been moving in the direction of specifying objects that require cluster admin permissions to apply (policies, role bindings) in //cluster/kube/k0 instead of in the app jsonnet
- namespace admins CAN delete the namespace, making `kubecfg delete` unexpectedly dangerous (especially if a namespace contains more than just the contents of the file being applied - common with personal namespaces)
- `.Contain()` is a common operation, and it shows up in lines that are pretty long, so `ns.Contain()` is preferable to `app.ns.Contain()` or `service.namespace.Contain()`
Change-Id: Ie4ea825376dbf6faa175179054f3ee3de2253ae0
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1804
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/ops/sso/kube/sso.libsonnet b/ops/sso/kube/sso.libsonnet
index 214c921..12c111f 100644
--- a/ops/sso/kube/sso.libsonnet
+++ b/ops/sso/kube/sso.libsonnet
@@ -19,9 +19,9 @@
},
},
- ns: kube.Namespace(app.cfg.namespace),
+ local ns = kube.Namespace(app.cfg.namespace),
- deployment: app.ns.Contain(kube.Deployment("sso")) {
+ deployment: ns.Contain(kube.Deployment("sso")) {
spec+: {
replicas: 1,
template+: {
@@ -94,7 +94,7 @@
},
},
- svc: app.ns.Contain(kube.Service("sso")) {
+ svc: ns.Contain(kube.Service("sso")) {
target:: app.deployment,
spec+: {
ports: [
@@ -104,7 +104,7 @@
},
},
- ingress: app.ns.Contain(kube.SimpleIngress("sso")) {
+ ingress: ns.Contain(kube.SimpleIngress("sso")) {
hosts:: [cfg.domain],
target_service:: app.svc,
},