Adding ImagePullPolicy config option to OSM Charms 20/11120/2
authorsousaedu <eduardo.sousa@canonical.com>
Tue, 24 Aug 2021 18:57:24 +0000 (19:57 +0100)
committersousaedu <eduardo.sousa@canonical.com>
Wed, 25 Aug 2021 15:04:33 +0000 (16:04 +0100)
Change-Id: I04ad8444088e8a360755dc4e22b7ea53942682b2
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
26 files changed:
installers/charm/grafana/config.yaml
installers/charm/grafana/src/charm.py
installers/charm/kafka-exporter/config.yaml
installers/charm/kafka-exporter/src/charm.py
installers/charm/keystone/config.yaml
installers/charm/keystone/src/charm.py
installers/charm/lcm/config.yaml
installers/charm/lcm/src/charm.py
installers/charm/mon/config.yaml
installers/charm/mon/src/charm.py
installers/charm/mongodb-exporter/config.yaml
installers/charm/mongodb-exporter/src/charm.py
installers/charm/mysqld-exporter/config.yaml
installers/charm/mysqld-exporter/src/charm.py
installers/charm/nbi/config.yaml
installers/charm/nbi/src/charm.py
installers/charm/ng-ui/config.yaml
installers/charm/ng-ui/src/charm.py
installers/charm/pla/config.yaml
installers/charm/pla/src/charm.py
installers/charm/pol/config.yaml
installers/charm/pol/src/charm.py
installers/charm/prometheus/config.yaml
installers/charm/prometheus/src/charm.py
installers/charm/ro/config.yaml
installers/charm/ro/src/charm.py

index 3a7e63f..632f212 100644 (file)
@@ -57,3 +57,9 @@ options:
     type: boolean
     description: Enable OSM System monitoring dashboards
     default: false
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index 28be79a..9bc612e 100755 (executable)
@@ -54,6 +54,7 @@ class ConfigModel(ModelValidator):
     ingress_class: Optional[str]
     ingress_whitelist_source_range: Optional[str]
     tls_secret_name: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("max_file_size")
     def validate_max_file_size(cls, v):
@@ -75,6 +76,18 @@ class ConfigModel(ModelValidator):
             ip_network(v)
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class GrafanaCharm(CharmedOsmBase):
     """GrafanaCharm Charm."""
@@ -137,7 +150,9 @@ class GrafanaCharm(CharmedOsmBase):
         # Create Builder for the PodSpec
         pod_spec_builder = PodSpecV3Builder()
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_http_readiness_probe(
             "/api/health",
index 706e330..456c9c4 100644 (file)
@@ -46,3 +46,9 @@ options:
     type: string
     description: Name of the cluster issuer for TLS certificates
     default: ""
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index a15abc8..fd24964 100755 (executable)
@@ -52,6 +52,7 @@ class ConfigModel(ModelValidator):
     ingress_class: Optional[str]
     ingress_whitelist_source_range: Optional[str]
     tls_secret_name: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("site_url")
     def validate_site_url(cls, v):
@@ -67,6 +68,18 @@ class ConfigModel(ModelValidator):
             ip_network(v)
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class KafkaExporterCharm(CharmedOsmBase):
     def __init__(self, *args) -> NoReturn:
@@ -163,7 +176,9 @@ class KafkaExporterCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_http_readiness_probe(
             path="/api/health",
index 9a7acd5..945ea48 100644 (file)
@@ -42,6 +42,12 @@ options:
     type: string
     description: Ingress URL
     default: ""
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
   region_id:
     type: string
     description: Region ID to be created when starting the service
index 1dd0ba5..4e04e88 100755 (executable)
@@ -84,6 +84,7 @@ class ConfigModel(ModelValidator):
     mysql_host: Optional[str]
     mysql_port: Optional[int]
     mysql_root_password: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("max_file_size")
     def validate_max_file_size(cls, v):
@@ -111,6 +112,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("Mysql port out of range")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class ConfigLdapModel(ModelValidator):
     ldap_enabled: bool
@@ -261,7 +274,9 @@ class KeystoneCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
 
         # Build files
index dcebce8..27c43e5 100644 (file)
@@ -274,3 +274,9 @@ options:
     description: CA certificates to validate access to Helm repository
     type: string
     default: ""
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index fecd1b3..9d7f552 100755 (executable)
@@ -110,6 +110,7 @@ class ConfigModel(ModelValidator):
     vca_model_config_update_status_hook_interval: Optional[str]
     vca_stablerepourl: Optional[str]
     vca_helm_ca_certs: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("log_level")
     def validate_log_level(cls, v):
@@ -123,6 +124,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("mongodb_uri is not properly formed")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class LcmCharm(CharmedOsmBase):
     def __init__(self, *args) -> NoReturn:
@@ -167,7 +180,9 @@ class LcmCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_envs(
             {
index d06b68d..ee593ff 100644 (file)
@@ -87,3 +87,9 @@ options:
         name: name of the file for the certificate
         content: base64 content of the certificate
       The path for the files is /certs.
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index 8c0a6bc..1b7c74b 100755 (executable)
@@ -80,6 +80,7 @@ class ConfigModel(ModelValidator):
     grafana_user: str
     grafana_password: str
     certificates: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("log_level")
     def validate_log_level(cls, v):
@@ -99,6 +100,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("mongodb_uri is not properly formed")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
     @property
     def certificates_dict(cls):
         return _extract_certificates(cls.certificates) if cls.certificates else {}
@@ -167,7 +180,9 @@ class MonCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         certs_files = self._build_cert_files(config)
 
         if certs_files:
index 727598b..eb19d5b 100644 (file)
@@ -49,3 +49,9 @@ options:
   mongodb_uri:
     type: string
     description: MongoDB URI (external database)
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index 149940a..f4c232a 100755 (executable)
@@ -53,6 +53,7 @@ class ConfigModel(ModelValidator):
     ingress_whitelist_source_range: Optional[str]
     tls_secret_name: Optional[str]
     mongodb_uri: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("site_url")
     def validate_site_url(cls, v):
@@ -74,6 +75,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("mongodb_uri is not properly formed")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class MongodbExporterCharm(CharmedOsmBase):
     def __init__(self, *args) -> NoReturn:
@@ -173,7 +186,9 @@ class MongodbExporterCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_http_readiness_probe(
             path="/api/health",
index a7702a3..c25886f 100644 (file)
@@ -49,3 +49,9 @@ options:
   mysql_uri:
     type: string
     description: MySQL URI (external database)
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index bcd43b5..adbb519 100755 (executable)
@@ -53,6 +53,7 @@ class ConfigModel(ModelValidator):
     ingress_whitelist_source_range: Optional[str]
     tls_secret_name: Optional[str]
     mysql_uri: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("site_url")
     def validate_site_url(cls, v):
@@ -74,6 +75,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("mysql_uri is not properly formed")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class MysqlExporterCharm(CharmedOsmBase):
     def __init__(self, *args) -> NoReturn:
@@ -173,7 +186,9 @@ class MysqlExporterCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_http_readiness_probe(
             path="/api/health",
index 7f32752..9c35366 100644 (file)
@@ -72,3 +72,9 @@ options:
   mongodb_uri:
     type: string
     description: MongoDB URI (external database)
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index d3a2251..938a75a 100755 (executable)
@@ -61,6 +61,7 @@ class ConfigModel(ModelValidator):
     ingress_whitelist_source_range: Optional[str]
     tls_secret_name: Optional[str]
     mongodb_uri: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("auth_backend")
     def validate_auth_backend(cls, v):
@@ -100,6 +101,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("mongodb_uri is not properly formed")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class NbiCharm(CharmedOsmBase):
     def __init__(self, *args) -> NoReturn:
@@ -180,7 +193,9 @@ class NbiCharm(CharmedOsmBase):
         )
 
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_tcpsocket_readiness_probe(
             PORT,
index 39d3b2d..49226b7 100644 (file)
@@ -54,3 +54,9 @@ options:
     type: string
     description: Name of the cluster issuer for TLS certificates
     default: ""
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index 5388466..cf0b091 100755 (executable)
@@ -54,6 +54,7 @@ class ConfigModel(ModelValidator):
     ingress_class: Optional[str]
     ingress_whitelist_source_range: Optional[str]
     tls_secret_name: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("port")
     def validate_port(cls, v):
@@ -81,6 +82,18 @@ class ConfigModel(ModelValidator):
             ip_network(v)
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class NgUiCharm(CharmedOsmBase):
     def __init__(self, *args) -> NoReturn:
@@ -121,7 +134,9 @@ class NgUiCharm(CharmedOsmBase):
         # Create Builder for the PodSpec
         pod_spec_builder = PodSpecV3Builder()
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=config.port)
         container = container_builder.build()
         container_builder.add_tcpsocket_readiness_probe(
index 1820188..75b19d8 100644 (file)
@@ -27,3 +27,9 @@ options:
   mongodb_uri:
     type: string
     description: MongoDB URI (external database)
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index d9dfaa4..2a08ea5 100755 (executable)
@@ -46,6 +46,7 @@ class ConfigModel(ModelValidator):
     database_commonkey: str
     mongodb_uri: Optional[str]
     log_level: str
+    image_pull_policy: Optional[str]
 
     @validator("log_level")
     def validate_log_level(cls, v):
@@ -59,6 +60,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("mongodb_uri is not properly formed")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class PlaCharm(CharmedOsmBase):
     def __init__(self, *args) -> NoReturn:
@@ -97,7 +110,9 @@ class PlaCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_envs(
             {
index 909235e..7b64f57 100644 (file)
@@ -32,3 +32,9 @@ options:
     description: |
       Mysql URI with the following format:
         mysql://<user>:<password>@<mysql_host>:<mysql_port>/<database>
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index 1ad1e26..727ffbe 100755 (executable)
@@ -49,6 +49,7 @@ class ConfigModel(ModelValidator):
     log_level: str
     mongodb_uri: Optional[str]
     mysql_uri: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("log_level")
     def validate_log_level(cls, v):
@@ -69,6 +70,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("mysql_uri is not properly formed")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class PolCharm(CharmedOsmBase):
     def __init__(self, *args) -> NoReturn:
@@ -114,7 +127,9 @@ class PolCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_envs(
             {
index c1c0fb9..6ce1613 100644 (file)
@@ -65,3 +65,9 @@ options:
     type: boolean
     description: Boolean to enable the web admin api
     default: false
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index e3e0e42..3dcb5d4 100755 (executable)
@@ -60,6 +60,7 @@ class ConfigModel(ModelValidator):
     ingress_whitelist_source_range: Optional[str]
     tls_secret_name: Optional[str]
     enable_web_admin_api: bool
+    image_pull_policy: Optional[str]
 
     @validator("web_subpath")
     def validate_web_subpath(cls, v):
@@ -87,6 +88,18 @@ class ConfigModel(ModelValidator):
             ip_network(v)
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
 
 class PrometheusCharm(CharmedOsmBase):
 
@@ -157,7 +170,9 @@ class PrometheusCharm(CharmedOsmBase):
         pod_spec_builder.add_container(backup_container)
 
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         container_builder.add_port(name=self.app.name, port=PORT)
         container_builder.add_http_readiness_probe(
             "/-/ready",
index 0d3c9a0..5bb0362 100644 (file)
@@ -70,3 +70,9 @@ options:
         name: name of the file for the certificate
         content: base64 content of the certificate
       The path for the files is /certs.
+  image_pull_policy:
+    type: string
+    description: |
+      ImagePullPolicy configuration for the pod.
+      Possible values: always, ifnotpresent, never
+    default: always
index 951f281..d87007e 100755 (executable)
@@ -73,6 +73,7 @@ class ConfigModel(ModelValidator):
     ro_database: str
     openmano_tenant: str
     certificates: Optional[str]
+    image_pull_policy: Optional[str]
 
     @validator("log_level")
     def validate_log_level(cls, v):
@@ -98,6 +99,18 @@ class ConfigModel(ModelValidator):
             raise ValueError("Mysql port out of range")
         return v
 
+    @validator("image_pull_policy")
+    def validate_image_pull_policy(cls, v):
+        values = {
+            "always": "Always",
+            "ifnotpresent": "IfNotPresent",
+            "never": "Never",
+        }
+        v = v.lower()
+        if v not in values.keys():
+            raise ValueError("value must be always, ifnotpresent or never")
+        return values[v]
+
     @property
     def certificates_dict(cls):
         return _extract_certificates(cls.certificates) if cls.certificates else {}
@@ -196,7 +209,9 @@ class RoCharm(CharmedOsmBase):
         pod_spec_builder = PodSpecV3Builder()
 
         # Build Container
-        container_builder = ContainerV3Builder(self.app.name, image_info)
+        container_builder = ContainerV3Builder(
+            self.app.name, image_info, config.image_pull_policy
+        )
         certs_files = self._build_cert_files(config)
 
         if certs_files: