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/personal/radex/wordpress/prod.jsonnet b/personal/radex/wordpress/prod.jsonnet
index 47e71e7..d8aca0b 100644
--- a/personal/radex/wordpress/prod.jsonnet
+++ b/personal/radex/wordpress/prod.jsonnet
@@ -18,9 +18,9 @@
wordpress: { secretKeyRef: { name: cfg.name, key: 'wordpress_password' } },
},
- ns: kube.Namespace(cfg.namespace),
+ local ns = kube.Namespace(cfg.namespace),
- deployment: top.ns.Contain(kube.Deployment(cfg.name)) {
+ deployment: ns.Contain(kube.Deployment(cfg.name)) {
spec+: {
replicas: 1,
template+: {
@@ -50,11 +50,11 @@
},
},
- service: top.ns.Contain(kube.Service(cfg.name)) {
+ service: ns.Contain(kube.Service(cfg.name)) {
target:: top.deployment,
},
- ingress: top.ns.Contain(kube.SimpleIngress(cfg.name)) {
+ ingress: ns.Contain(kube.SimpleIngress(cfg.name)) {
hosts:: [cfg.domain],
target_service:: top.service,
},
@@ -62,12 +62,12 @@
mysql: {
local mysql = self,
- volume: top.ns.Contain(kube.PersistentVolumeClaim("wordpress-mysql")) {
+ volume: ns.Contain(kube.PersistentVolumeClaim("wordpress-mysql")) {
storage:: cfg.storageSize,
storageClass:: cfg.storageClassName,
},
- deployment: top.ns.Contain(kube.Deployment("wordpress-mysql")) {
+ deployment: ns.Contain(kube.Deployment("wordpress-mysql")) {
spec+: {
replicas: 1,
template+: {
@@ -100,7 +100,7 @@
}
},
- service: top.ns.Contain(kube.Service("wordpress-mysql")) {
+ service: ns.Contain(kube.Service("wordpress-mysql")) {
target:: mysql.deployment,
},
},