Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kf 3996 istio-pilot control plane configurable images with set #321

Merged
merged 11 commits into from
Aug 31, 2023
12 changes: 12 additions & 0 deletions charms/istio-pilot/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ options:
type: string
default: istio-gateway
description: Name to use as a default gateway
image-configuration:
default: |
pilot-image: 'pilot' # values.pilot.image
global-tag: '1.17.3' # values.global.tag
global-hub: 'docker.io/istio' # values.global.hub
global-proxy-image: 'proxyv2' # values.global.proxy.image
global-proxy-init-image: 'proxyv2' # values.global.proxy_init.image
grpc-bootstrap-init: 'busybox:1.28'
i-chvets marked this conversation as resolved.
Show resolved Hide resolved
description: >
YAML or JSON formatted input defining image configuration to use when installing the Istio control plane.
For reference https://istio.io/v1.5/docs/reference/config/installation-options/
type: string
gateway-service-name:
type: string
default: istio-ingressgateway-workload
Expand Down
31 changes: 28 additions & 3 deletions charms/istio-pilot/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import List, Optional

import tenacity
import yaml
from charmed_kubeflow_chisme.exceptions import ErrorWithStatus, GenericCharmRuntimeError
from charmed_kubeflow_chisme.kubernetes import (
KubernetesResourceHandler,
Expand Down Expand Up @@ -52,6 +53,7 @@
"https": 8443,
}
GATEWAY_TEMPLATE_FILES = ["src/manifests/gateway.yaml.j2"]
IMAGE_CONFIGURATION = "image-configuration"
KRH_GATEWAY_SCOPE = "gateway"
METRICS_PORT = 15014
INGRESS_AUTH_RELATION_NAME = "ingress-auth"
Expand Down Expand Up @@ -155,19 +157,42 @@ def __init__(self, *args):
)
self.grafana_dashboards = GrafanaDashboardProvider(self, relation_name="grafana-dashboard")

def _get_image_config(self):
"""Retrieve and return image configuration."""
image_config = yaml.safe_load(self.model.config[IMAGE_CONFIGURATION])
return image_config

def install(self, _):
"""Install charm."""
self._log_and_set_status(MaintenanceStatus("Deploying Istio control plane"))

image_config = self._get_image_config()
pilot_image = image_config["pilot-image"]
global_tag = image_config["global-tag"]
global_hub = image_config["global-hub"]
global_proxy_image = image_config["global-proxy-image"]
global_proxy_init_image = image_config["global-proxy-init-image"]

# Call istioctl install and set parameters based on image configuration
subprocess.check_call(
[
"./istioctl",
"install",
"-y",
"-s",
"--set",
"profile=minimal",
"-s",
f"values.global.istioNamespace={self.model.name}",
"--set",
"values.global.istioNamespace=kubeflow",
"--set",
f"values.pilot.image={pilot_image}",
"--set",
f"values.global.tag={global_tag}",
"--set",
f"values.global.hub={global_hub}",
"--set",
f"values.global.proxy.image={global_proxy_image}",
"--set",
f"values.global.proxy_init.image={global_proxy_init_image}",
]
)

Expand Down
8 changes: 8 additions & 0 deletions charms/istio-pilot/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,14 @@ def test_xor(self, left, right, expected):
"""Test that the xor helper function works as expected."""
assert _xor(left, right) is expected

def test_get_config(self, harness):
"""Test configuration retrieval function."""
harness.begin()
image_config = harness.charm._get_image_config()
assert "pilot-image" in image_config.keys()
assert "pilot" == image_config["pilot-image"]
assert "proxyv2" == image_config["global-proxy-image"]


class TestCharmUpgrade:
"""Tests for charm upgrade handling."""
Expand Down