From e53976d33c7611991c8a33344fd2f73211096c6e Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 5 Jun 2021 00:11:36 +0200 Subject: ready tanka deploy for CI --- .gitignore | 1 + deploy/environments/production/main.jsonnet | 40 +++++++++++++++++++++++++++++ deploy/jsonnetfile.json | 11 +++++++- deploy/jsonnetfile.lock.json | 18 ++++++++++--- deploy/lib/catinator.libsonnet | 6 ++--- deploy/lib/k.libsonnet | 2 +- deploy/main.jsonnet | 10 -------- deploy/spec.json | 13 ---------- 8 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 deploy/environments/production/main.jsonnet delete mode 100644 deploy/main.jsonnet delete mode 100644 deploy/spec.json diff --git a/.gitignore b/.gitignore index f182a35..2cfb519 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target config.json +/deploy/vendor diff --git a/deploy/environments/production/main.jsonnet b/deploy/environments/production/main.jsonnet new file mode 100644 index 0000000..175fbab --- /dev/null +++ b/deploy/environments/production/main.jsonnet @@ -0,0 +1,40 @@ +local k = import 'ksonnet-util/kausal.libsonnet'; +local util = import 'util/main.libsonnet'; + +function(tag, namespace, envSlug=null, projectPathSlug=null) + (util.inlineSpec('https://control.kube.cat:6443', namespace, envSlug, projectPathSlug)) + + { + _config:: self.data._config, + catinator:: self.data.catinator, + data: (import 'catinator.libsonnet') + { + _config+:: { + catinator+: { + image+: { + tag: tag, + }, + config: importstr '../../../config.toml', + }, + }, + catinator+: { + local egress = util.cilium.egressNatPolicy, + local statefulset = k.apps.v1.statefulSet, + local container = k.core.v1.container, + + statefulset+: + statefulset.spec.template.spec.withInitContainers([ + container.new('waitForEgress', 'docker.io/busybox:latest') + + container.withCommand(['/bin/sleep', '30']), + ]), + + egress: + egress.new('catinator') + + egress.withEgressSourceIP('178.63.224.13') + + egress.withDestinationCIDRs(['0.0.0.0/0']) + + egress.withPodSelector( + egress.podSelector.withMatchLabels({ + 'io.kubernetes.pod.namespace': namespace, + }) + ), + }, + }, + } diff --git a/deploy/jsonnetfile.json b/deploy/jsonnetfile.json index ad98fc7..76cf8e3 100644 --- a/deploy/jsonnetfile.json +++ b/deploy/jsonnetfile.json @@ -14,7 +14,16 @@ "source": { "git": { "remote": "https://github.com/jsonnet-libs/k8s-alpha", - "subdir": "1.19" + "subdir": "1.21" + } + }, + "version": "master" + }, + { + "source": { + "git": { + "remote": "ssh://git@gitlab.com/cocainefarm/k8s/lib/util.git", + "subdir": "" } }, "version": "master" diff --git a/deploy/jsonnetfile.lock.json b/deploy/jsonnetfile.lock.json index 0eebc29..56fae34 100644 --- a/deploy/jsonnetfile.lock.json +++ b/deploy/jsonnetfile.lock.json @@ -8,18 +8,28 @@ "subdir": "ksonnet-util" } }, - "version": "188bf1e03f0c7dcaaa53b916459a8afdc24a2c83", + "version": "0e1f8c4362c036ae14afafed4f744216b306044d", "sum": "jelt5QWEerVPLHHZN6Ga0B4OQ/MLBl+OLj3kVzTET+Y=" }, { "source": { "git": { "remote": "https://github.com/jsonnet-libs/k8s-alpha", - "subdir": "1.19" + "subdir": "1.21" } }, - "version": "50fa5748382fbc0d6fb34105835fd07acaf0195f", - "sum": "OXTug8dGtUKG5MGkSdEvMllGfPitqG1kdTk4pPVSH8k=" + "version": "b3200f1ead8ebb74932673a41748194950564686", + "sum": "QVUm2JrNnhjorXlfsNBDV0uvPgSWUolMYG9UzWLo1qQ=" + }, + { + "source": { + "git": { + "remote": "ssh://git@gitlab.com/cocainefarm/k8s/lib/util.git", + "subdir": "" + } + }, + "version": "5c9688362ec0b5609de9aa470a1c3c070e16d28a", + "sum": "mSOvwUmBAeSSrcAZN+ke5OwoDifnx50Gv8JRlUJ7D4E=" } ], "legacyImports": false diff --git a/deploy/lib/catinator.libsonnet b/deploy/lib/catinator.libsonnet index b4144fe..afd383c 100644 --- a/deploy/lib/catinator.libsonnet +++ b/deploy/lib/catinator.libsonnet @@ -4,7 +4,7 @@ name: "catinator", image: { repo: "kube.cat/cocainefarm/catinator", - tag: "1.0.0" + tag: "1.0.1" }, config: "", secret: "catinator-password" @@ -22,7 +22,7 @@ env.new(name=name, value=value)), catinator: { - deployment: statefulset.new( + statefulset: statefulset.new( name=$._config.catinator.name , replicas=1 , containers=[ @@ -37,7 +37,7 @@ ) + k.util.configMapVolumeMount($.catinator.configmap, "/etc/catinator") + statefulset.spec.withServiceName($.catinator.service.metadata.name), - service: k.util.serviceFor(self.deployment) + service.spec.withClusterIP("None"), + service: k.util.serviceFor(self.statefulset) + service.spec.withClusterIP("None"), configmap: k.core.v1.configMap.new(name="%s-config" % $._config.catinator.name, data={ "config.toml": $._config.catinator.config, }) diff --git a/deploy/lib/k.libsonnet b/deploy/lib/k.libsonnet index 4b0d3fb..4102b72 100644 --- a/deploy/lib/k.libsonnet +++ b/deploy/lib/k.libsonnet @@ -1 +1 @@ -import 'github.com/jsonnet-libs/k8s-alpha/1.19/main.libsonnet' +import 'github.com/jsonnet-libs/k8s-alpha/1.21/main.libsonnet' diff --git a/deploy/main.jsonnet b/deploy/main.jsonnet deleted file mode 100644 index 4b9a732..0000000 --- a/deploy/main.jsonnet +++ /dev/null @@ -1,10 +0,0 @@ -(import "catinator.libsonnet") + -{ - _config+:: { - catinator+: { - config: importstr '../config.toml' - } - }, - - local util = import "util/main.libsonnet", -} diff --git a/deploy/spec.json b/deploy/spec.json deleted file mode 100644 index f127bec..0000000 --- a/deploy/spec.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "apiVersion": "tanka.dev/v1alpha1", - "kind": "Environment", - "metadata": { - "name": "default" - }, - "spec": { - "apiServer": "https://control.kube.cat:6443", - "namespace": "gnulag", - "resourceDefaults": {}, - "expectVersions": {} - } -} -- cgit v1.2.3