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/app/matrix/lib/coturn.libsonnet b/app/matrix/lib/coturn.libsonnet
index f1b127b..cfb5024 100644
--- a/app/matrix/lib/coturn.libsonnet
+++ b/app/matrix/lib/coturn.libsonnet
@@ -15,8 +15,9 @@
},
ns:: error "ns needs to be provided",
+ local ns = app.ns,
- configMap: app.ns.Contain(kube.ConfigMap("coturn")) {
+ configMap: ns.Contain(kube.ConfigMap("coturn")) {
data: {
"coturn.conf": |||
# VoIP traffic is all UDP. There is no reason to let users connect to arbitrary TCP endpoints via the relay.
@@ -59,12 +60,12 @@
},
},
- dataVolume: app.ns.Contain(kube.PersistentVolumeClaim("coturn-data")) {
+ dataVolume: ns.Contain(kube.PersistentVolumeClaim("coturn-data")) {
storage:: "10Gi",
storageClass:: cfg.storageClassName,
},
- deployment: app.ns.Contain(kube.Deployment("coturn")) {
+ deployment: ns.Contain(kube.Deployment("coturn")) {
spec+: {
replicas: 1,
template+: {
@@ -129,7 +130,7 @@
},
},
- svcTCP: app.ns.Contain(kube.Service("coturn-tcp")) {
+ svcTCP: ns.Contain(kube.Service("coturn-tcp")) {
target:: app.deployment,
metadata+: {
annotations+: {
@@ -149,7 +150,7 @@
},
},
- svcUDP: app.ns.Contain(kube.Service("coturn-udp")) {
+ svcUDP: ns.Contain(kube.Service("coturn-udp")) {
target:: app.deployment,
metadata+: {
annotations+: {