From fa75eca9077591fcac5f0ea7f07a2ce5e60c8294 Mon Sep 17 00:00:00 2001 From: David Garcia Date: Wed, 4 Nov 2020 18:34:41 +0100 Subject: [PATCH] Add image_username and image_password to charms This commit will allow us to pull images for OSM components from a private docker registry, protected with username and password Change-Id: I854028d6abbb1cae07c61692ba73d08825763212 Signed-off-by: David Garcia --- installers/charm/lcm-k8s/config.yaml | 8 ++++++++ installers/charm/lcm-k8s/reactive/lcm.py | 1 - .../charm/lcm-k8s/reactive/spec_template.yaml | 5 ++++- installers/charm/mon-k8s/config.yaml | 8 ++++++++ installers/charm/mon-k8s/reactive/mon_k8s.py | 1 - .../charm/mon-k8s/reactive/spec_template.yaml | 5 ++++- installers/charm/nbi-k8s/config.yaml | 8 ++++++++ installers/charm/nbi-k8s/reactive/nbi.py | 1 - .../charm/nbi-k8s/reactive/spec_template.yaml | 5 ++++- installers/charm/ng-ui/config.yaml | 8 ++++++++ installers/charm/ng-ui/hooks/start | 1 - installers/charm/ng-ui/lib/ops | 1 - installers/charm/ng-ui/mod/operator | 1 - installers/charm/ng-ui/src/charm.py | 15 ++++++++++----- installers/charm/pla/config.yaml | 8 ++++++++ installers/charm/pla/hooks/install | 1 - installers/charm/pla/hooks/start | 1 - installers/charm/pla/hooks/upgrade-charm | 1 - installers/charm/pla/lib/ops | 1 - installers/charm/pla/mod/operator | 1 - installers/charm/pla/src/charm.py | 19 +++++++++++-------- installers/charm/pol-k8s/config.yaml | 8 ++++++++ installers/charm/pol-k8s/reactive/pol_k8s.py | 1 - .../charm/pol-k8s/reactive/spec_template.yaml | 5 ++++- installers/charm/ro-k8s/config.yaml | 8 ++++++++ installers/charm/ro-k8s/reactive/ro.py | 1 - .../charm/ro-k8s/reactive/spec_template.yaml | 5 ++++- installers/charm/ui-k8s/config.yaml | 8 ++++++++ .../charm/ui-k8s/reactive/spec_template.yaml | 5 ++++- installers/charm/ui-k8s/reactive/ui.py | 1 - 30 files changed, 109 insertions(+), 33 deletions(-) delete mode 120000 installers/charm/ng-ui/hooks/start delete mode 120000 installers/charm/ng-ui/lib/ops delete mode 160000 installers/charm/ng-ui/mod/operator delete mode 120000 installers/charm/pla/hooks/install delete mode 120000 installers/charm/pla/hooks/start delete mode 120000 installers/charm/pla/hooks/upgrade-charm delete mode 120000 installers/charm/pla/lib/ops delete mode 160000 installers/charm/pla/mod/operator diff --git a/installers/charm/lcm-k8s/config.yaml b/installers/charm/lcm-k8s/config.yaml index 25f6a71e..1f1c62bb 100644 --- a/installers/charm/lcm-k8s/config.yaml +++ b/installers/charm/lcm-k8s/config.yaml @@ -66,3 +66,11 @@ options: type: string description: OCI image default: opensourcemano/lcm:8 + image_username: + description: Docker repository username + type: string + default: "" + image_password: + description: Docker repository password + type: string + default: "" diff --git a/installers/charm/lcm-k8s/reactive/lcm.py b/installers/charm/lcm-k8s/reactive/lcm.py index 1cb46610..87b6b2c2 100644 --- a/installers/charm/lcm-k8s/reactive/lcm.py +++ b/installers/charm/lcm-k8s/reactive/lcm.py @@ -138,7 +138,6 @@ def make_pod_spec(ro_host, ro_port, kafka_host, kafka_port, mongo_uri): data = { "name": md.get("name"), - "docker_image": cfg.get("image"), "ro_host": ro_host, "ro_port": ro_port, "kafka_host": kafka_host, diff --git a/installers/charm/lcm-k8s/reactive/spec_template.yaml b/installers/charm/lcm-k8s/reactive/spec_template.yaml index d8b51e77..b5f508bc 100644 --- a/installers/charm/lcm-k8s/reactive/spec_template.yaml +++ b/installers/charm/lcm-k8s/reactive/spec_template.yaml @@ -14,7 +14,10 @@ version: 2 containers: - name: %(name)s - image: %(docker_image)s + imageDetails: + imagePath: %(image)s + username: %(image_username)s + password: %(image_password)s ports: # This is a fake port; lcm doesn't listen, since it's just reading # and responding to the kafka bus. Fix this in post. diff --git a/installers/charm/mon-k8s/config.yaml b/installers/charm/mon-k8s/config.yaml index ddf8a812..069758fe 100644 --- a/installers/charm/mon-k8s/config.yaml +++ b/installers/charm/mon-k8s/config.yaml @@ -68,3 +68,11 @@ options: type: string description: OCI image default: opensourcemano/mon:8 + image_username: + description: Docker repository username + type: string + default: "" + image_password: + description: Docker repository password + type: string + default: "" diff --git a/installers/charm/mon-k8s/reactive/mon_k8s.py b/installers/charm/mon-k8s/reactive/mon_k8s.py index 79780e03..cd4d568d 100644 --- a/installers/charm/mon-k8s/reactive/mon_k8s.py +++ b/installers/charm/mon-k8s/reactive/mon_k8s.py @@ -114,7 +114,6 @@ def make_pod_spec(kafka_host, kafka_port, mongo_uri, prometheus_url): data = { "name": md.get("name"), - "docker_image": cfg.get("image"), "kafka_host": kafka_host, "kafka_port": kafka_port, "mongo_uri": mongo_uri, diff --git a/installers/charm/mon-k8s/reactive/spec_template.yaml b/installers/charm/mon-k8s/reactive/spec_template.yaml index c81e5a16..bc6cb079 100644 --- a/installers/charm/mon-k8s/reactive/spec_template.yaml +++ b/installers/charm/mon-k8s/reactive/spec_template.yaml @@ -14,7 +14,10 @@ version: 2 containers: - name: %(name)s - image: %(docker_image)s + imageDetails: + imagePath: %(image)s + username: %(image_username)s + password: %(image_password)s ports: - containerPort: %(advertised-port)s protocol: TCP diff --git a/installers/charm/nbi-k8s/config.yaml b/installers/charm/nbi-k8s/config.yaml index b9472900..a594f6e5 100755 --- a/installers/charm/nbi-k8s/config.yaml +++ b/installers/charm/nbi-k8s/config.yaml @@ -32,6 +32,14 @@ options: type: string description: OCI image default: opensourcemano/nbi:8 + image_username: + description: Docker repository username + type: string + default: "" + image_password: + description: Docker repository password + type: string + default: "" auth-backend: type: string description: Authentication backend ('internal' or 'keystone') diff --git a/installers/charm/nbi-k8s/reactive/nbi.py b/installers/charm/nbi-k8s/reactive/nbi.py index 855d8006..50187ad8 100644 --- a/installers/charm/nbi-k8s/reactive/nbi.py +++ b/installers/charm/nbi-k8s/reactive/nbi.py @@ -222,7 +222,6 @@ def make_pod_spec(kafka_host, kafka_port, mongo_uri, prometheus_uri): prometheus_host, prometheus_port = parse_hostport(prometheus_uri) data = { "name": md.get("name"), - "docker_image": cfg.get("image"), "mongo_uri": mongo_uri, "kafka_host": "{}".format(kafka_host), "kafka_port": "{}".format(kafka_port), diff --git a/installers/charm/nbi-k8s/reactive/spec_template.yaml b/installers/charm/nbi-k8s/reactive/spec_template.yaml index 5c030d96..f9a35b69 100644 --- a/installers/charm/nbi-k8s/reactive/spec_template.yaml +++ b/installers/charm/nbi-k8s/reactive/spec_template.yaml @@ -14,7 +14,10 @@ version: 2 containers: - name: %(name)s - image: %(docker_image)s + imageDetails: + imagePath: %(image)s + username: %(image_username)s + password: %(image_password)s ports: - containerPort: %(advertised-port)s protocol: TCP diff --git a/installers/charm/ng-ui/config.yaml b/installers/charm/ng-ui/config.yaml index a80a280e..022d150b 100644 --- a/installers/charm/ng-ui/config.yaml +++ b/installers/charm/ng-ui/config.yaml @@ -20,6 +20,14 @@ options: description: Docker image name type: string default: opensourcemano/ng-ui:8 + image_username: + description: Docker repository username + type: string + default: "" + image_password: + description: Docker repository password + type: string + default: "" port: description: Port number type: int diff --git a/installers/charm/ng-ui/hooks/start b/installers/charm/ng-ui/hooks/start deleted file mode 120000 index 25b1f68f..00000000 --- a/installers/charm/ng-ui/hooks/start +++ /dev/null @@ -1 +0,0 @@ -../src/charm.py \ No newline at end of file diff --git a/installers/charm/ng-ui/lib/ops b/installers/charm/ng-ui/lib/ops deleted file mode 120000 index d9341932..00000000 --- a/installers/charm/ng-ui/lib/ops +++ /dev/null @@ -1 +0,0 @@ -../mod/operator/ops \ No newline at end of file diff --git a/installers/charm/ng-ui/mod/operator b/installers/charm/ng-ui/mod/operator deleted file mode 160000 index a84ce877..00000000 --- a/installers/charm/ng-ui/mod/operator +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a84ce8776b368a8b2bccdb173716e342db9a6b36 diff --git a/installers/charm/ng-ui/src/charm.py b/installers/charm/ng-ui/src/charm.py index d9ad8f2a..6f5ca5b5 100755 --- a/installers/charm/ng-ui/src/charm.py +++ b/installers/charm/ng-ui/src/charm.py @@ -32,9 +32,6 @@ from ops.model import ( ) -sys.path.append("lib") - - logger = logging.getLogger(__name__) @@ -130,7 +127,11 @@ class NGUICharm(CharmBase): ] port = config["https_port"] if ssl_enabled else config["port"] ports = [ - {"name": "port", "containerPort": port, "protocol": "TCP", }, + { + "name": "port", + "containerPort": port, + "protocol": "TCP", + }, ] kubernetes = { @@ -166,7 +167,11 @@ class NGUICharm(CharmBase): "containers": [ { "name": self.framework.model.app.name, - "image": "{}".format(config["image"]), + "imageDetails": { + "imagePath": config["image"], + "username": config["image_username"], + "password": config["image_password"], + }, "ports": ports, "kubernetes": kubernetes, "files": files, diff --git a/installers/charm/pla/config.yaml b/installers/charm/pla/config.yaml index e0aeca41..f3318fc6 100644 --- a/installers/charm/pla/config.yaml +++ b/installers/charm/pla/config.yaml @@ -20,6 +20,14 @@ options: description: Docker image name type: string default: opensourcemano/pla:8 + image_username: + description: Docker repository username + type: string + default: "" + image_password: + description: Docker repository password + type: string + default: "" port: description: Port number type: int diff --git a/installers/charm/pla/hooks/install b/installers/charm/pla/hooks/install deleted file mode 120000 index 25b1f68f..00000000 --- a/installers/charm/pla/hooks/install +++ /dev/null @@ -1 +0,0 @@ -../src/charm.py \ No newline at end of file diff --git a/installers/charm/pla/hooks/start b/installers/charm/pla/hooks/start deleted file mode 120000 index 25b1f68f..00000000 --- a/installers/charm/pla/hooks/start +++ /dev/null @@ -1 +0,0 @@ -../src/charm.py \ No newline at end of file diff --git a/installers/charm/pla/hooks/upgrade-charm b/installers/charm/pla/hooks/upgrade-charm deleted file mode 120000 index 25b1f68f..00000000 --- a/installers/charm/pla/hooks/upgrade-charm +++ /dev/null @@ -1 +0,0 @@ -../src/charm.py \ No newline at end of file diff --git a/installers/charm/pla/lib/ops b/installers/charm/pla/lib/ops deleted file mode 120000 index d9341932..00000000 --- a/installers/charm/pla/lib/ops +++ /dev/null @@ -1 +0,0 @@ -../mod/operator/ops \ No newline at end of file diff --git a/installers/charm/pla/mod/operator b/installers/charm/pla/mod/operator deleted file mode 160000 index a84ce877..00000000 --- a/installers/charm/pla/mod/operator +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a84ce8776b368a8b2bccdb173716e342db9a6b36 diff --git a/installers/charm/pla/src/charm.py b/installers/charm/pla/src/charm.py index 785766de..16e7303f 100755 --- a/installers/charm/pla/src/charm.py +++ b/installers/charm/pla/src/charm.py @@ -29,9 +29,6 @@ from ops.model import ( ) -sys.path.append("lib") - - logger = logging.getLogger(__name__) @@ -85,7 +82,11 @@ class PLACharm(CharmBase): config = self.framework.model.config ports = [ - {"name": "port", "containerPort": config["port"], "protocol": "TCP", }, + { + "name": "port", + "containerPort": config["port"], + "protocol": "TCP", + }, ] config_spec = { @@ -103,7 +104,11 @@ class PLACharm(CharmBase): "containers": [ { "name": self.framework.model.app.name, - "image": config["image"], + "imageDetails": { + "imagePath": config["image"], + "username": config["image_username"], + "password": config["image_password"], + }, "ports": ports, "config": config_spec, } @@ -136,9 +141,7 @@ class PLACharm(CharmBase): self._apply_spec() def on_mongo_relation_changed(self, event): - mongodb_uri = event.relation.data[event.unit].get( - "connection_string" - ) + mongodb_uri = event.relation.data[event.unit].get("connection_string") if mongodb_uri and self.state.mongodb_uri != mongodb_uri: self.state.mongodb_uri = mongodb_uri self._apply_spec() diff --git a/installers/charm/pol-k8s/config.yaml b/installers/charm/pol-k8s/config.yaml index 8cfd8bf6..d33a715f 100644 --- a/installers/charm/pol-k8s/config.yaml +++ b/installers/charm/pol-k8s/config.yaml @@ -24,3 +24,11 @@ options: type: string description: OCI image default: opensourcemano/pol:8 + image_username: + description: Docker repository username + type: string + default: "" + image_password: + description: Docker repository password + type: string + default: "" diff --git a/installers/charm/pol-k8s/reactive/pol_k8s.py b/installers/charm/pol-k8s/reactive/pol_k8s.py index 5629b4ba..5d56c27d 100644 --- a/installers/charm/pol-k8s/reactive/pol_k8s.py +++ b/installers/charm/pol-k8s/reactive/pol_k8s.py @@ -100,7 +100,6 @@ def make_pod_spec(kafka_host, kafka_port, mongo_uri): cfg = config() data = { "name": md.get("name"), - "docker_image": cfg.get("image"), "kafka_host": kafka_host, "kafka_port": kafka_port, "mongo_uri": mongo_uri, diff --git a/installers/charm/pol-k8s/reactive/spec_template.yaml b/installers/charm/pol-k8s/reactive/spec_template.yaml index de7d4a21..d0c5823f 100644 --- a/installers/charm/pol-k8s/reactive/spec_template.yaml +++ b/installers/charm/pol-k8s/reactive/spec_template.yaml @@ -14,7 +14,10 @@ version: 2 containers: - name: %(name)s - image: %(docker_image)s + imageDetails: + imagePath: %(image)s + username: %(image_username)s + password: %(image_password)s ports: # This is a fake port; lcm doesn't listen, since it's just reading # and responding to the kafka bus. Fix this in post. diff --git a/installers/charm/ro-k8s/config.yaml b/installers/charm/ro-k8s/config.yaml index a18e4958..31eaca8a 100755 --- a/installers/charm/ro-k8s/config.yaml +++ b/installers/charm/ro-k8s/config.yaml @@ -32,3 +32,11 @@ options: type: string description: OCI image default: opensourcemano/ro:8 + image_username: + description: Docker repository username + type: string + default: "" + image_password: + description: Docker repository password + type: string + default: "" diff --git a/installers/charm/ro-k8s/reactive/ro.py b/installers/charm/ro-k8s/reactive/ro.py index 8ad6f98c..8f91b4bd 100644 --- a/installers/charm/ro-k8s/reactive/ro.py +++ b/installers/charm/ro-k8s/reactive/ro.py @@ -114,7 +114,6 @@ def make_pod_spec( data = { "name": md.get("name"), - "docker_image": cfg.get("image"), "mysql_host": mysql_host, "mysql_port": mysql_port, "mysql_user": mysql_user, diff --git a/installers/charm/ro-k8s/reactive/spec_template.yaml b/installers/charm/ro-k8s/reactive/spec_template.yaml index f4f7c9c3..f2b35350 100644 --- a/installers/charm/ro-k8s/reactive/spec_template.yaml +++ b/installers/charm/ro-k8s/reactive/spec_template.yaml @@ -16,7 +16,10 @@ service: scalePolicy: serial containers: - name: %(name)s - image: %(docker_image)s + imageDetails: + imagePath: %(image)s + username: %(image_username)s + password: %(image_password)s kubernetes: readinessProbe: httpGet: diff --git a/installers/charm/ui-k8s/config.yaml b/installers/charm/ui-k8s/config.yaml index 8e24da0a..d4321ae9 100755 --- a/installers/charm/ui-k8s/config.yaml +++ b/installers/charm/ui-k8s/config.yaml @@ -28,3 +28,11 @@ options: type: string description: OCI image default: opensourcemano/light-ui:8 + image_username: + description: Docker repository username + type: string + default: "" + image_password: + description: Docker repository password + type: string + default: "" diff --git a/installers/charm/ui-k8s/reactive/spec_template.yaml b/installers/charm/ui-k8s/reactive/spec_template.yaml index b63c2104..4b3eef3e 100644 --- a/installers/charm/ui-k8s/reactive/spec_template.yaml +++ b/installers/charm/ui-k8s/reactive/spec_template.yaml @@ -14,7 +14,10 @@ version: 2 containers: - name: %(name)s - image: %(docker_image)s + imageDetails: + imagePath: %(image)s + username: %(image_username)s + password: %(image_password)s ports: - containerPort: %(advertised-port)s protocol: TCP diff --git a/installers/charm/ui-k8s/reactive/ui.py b/installers/charm/ui-k8s/reactive/ui.py index 5ca81433..eb53daf2 100644 --- a/installers/charm/ui-k8s/reactive/ui.py +++ b/installers/charm/ui-k8s/reactive/ui.py @@ -111,7 +111,6 @@ def make_pod_spec( data = { "name": md.get("name"), - "docker_image": cfg.get("image"), "mysql_host": mysql_host, "mysql_port": mysql_port, "mysql_user": mysql_user, -- 2.25.1