k8s.mk

k8s-chart-version

Synopsis: make k8s-chart-version

Hooks: none

Variables:

Variable

Description

K8S_CHART

<Helm Chart to check> - default is project name (directory)

K8S_HELM_REPOSITORY

<Helm Chart repository> - default is https://artefact.skao.int/repository/helm-internal

Shows the latest version of K8S_CHART in K8S_HELM_REPOSITORY, by default project chart version in Central Artefact Repository. Do not confuse this with the current local version!

k8s-vars

Synopsis: make k8s-vars

Hooks: none

Describe the current Kubernetes context and Helm Chart.

k8s-namespace

Synopsis: make k8s-namespace

Hooks: none

Variables:

Variable

Description

KUBE_NAMESPACE

<Kubernetes Namespace to allocate> - default is project name (directory)

K8S_SKIP_NAMESPACE

<skip the target> - default is false

Create the Namespace indicated in KUBE_NAMESPACE. If you don’t have enough permissions to create namespace, set K8S_SKIP_NAMESPACE flag

k8s-namespace-credentials

Synopsis: make k8s-namespace-credentials

Hooks: none

Variables:

Variable

Description

K8S_NAMESPACES

<Kubernetes Namespace to add to the credentials> - default is KUBE_NAMESPACE

K8S_SERVICE_ACCOUNT

<name of the k8s service account> - default is concatenation of the namespaces with “-sa” suffix

Create a Kubeconfig scoped to a namespace. If you don’t have enough permissions to create namespace, set K8S_SKIP_NAMESPACE flag

k8s-delete-namespace

Synopsis: make k8s-delete-namespace

Hooks: none

Variables:

Variable

Description

KUBE_NAMESPACE

<Kubernetes Namespace to delete> - default is project name (directory)

K8S_SKIP_NAMESPACE

<skip the target> - default is false

Delete the Namespace indicated in KUBE_NAMESPACE. If you don’t have enough permissions to create namespace, set K8S_SKIP_NAMESPACE flag

k8s-clean

Synopsis: make k8s-clean

Hooks: none

Purge common temp Helm Chart and Python temp test files. Python temp test files are deleted as they are mostly used in testing against Kubernetes as well.

k8s-dep-build

Synopsis: make k8s-dep-build

Hooks: k8s-pre-dep-build, k8s-post-dep-build

Variables:

Variable

Description

K8S_CHARTS

<list of chart names for ./charts directory> - defaults to repository name

Iterate over K8S_CHARTS list of chart names and pull and build the sub-chart dependencies described in each respective Chart.yaml file.

k8s-install-chart

Synopsis: make k8s-install-chart

Hooks: k8s-pre-install-chart, k8s-post-install-chart

Variables:

Variable

Description

HELM_RELEASE

<Helm relase name> - default ‘test’

K8S_UMBRELLA_CHART_PATH

<a Helm compatible path name for a chart to install> - default ./charts/$(K8S_CHART)/

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

K8S_CHART_PARAMS

<list of additional parameters to pass to helm> - default empty

Deploy an instance (HELM_RELEASE) of a given Helm Chart into a specified Kubernetes Namespace (KUBE_NAMESPACE), with a configurable set of parameters (K8S_CHART_PARAMS).

k8s-install-chart-car

Synopsis: make k8s-install-chart-car

Hooks: k8s-pre-install-chart-car:, k8s-post-install-chart-car

Variables:

Variable

Description

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

K8S_CHART_PARAMS

<list of additional parameters to pass to helm> - default empty

K8S_CHART

chart name - default on the repository’s Makefile

K8S_HELM_REPOSITORY

Helm repository to retrieve the chart - defaults to ‘https://artefact.skao.int/repository/helm-internal

Deploys a chart from CAR(https://artefact.skao.int/repository/helm-internal/)

k8s-template-chart

Synopsis: make k8s-template-chart

Hooks: k8s-pre-template-chart, k8s-post-template-chart

Variables:

Variable

Description

HELM_RELEASE

<Helm relase name> - default ‘test’

K8S_UMBRELLA_CHART_PATH

<a Helm compatible path name for a chart to template> - default ./charts/$(K8S_CHART)/

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

K8S_CHART_PARAMS

<list of additional parameters to pass to helm> - default empty

Render a given Helm Chart(HELM_RELEASE) for a specified Kubernetes Namespace(KUBE_NAMESPACE), with a configurable set of parameters(K8S_CHART_PARAMS), as a set of YAML manifest files.

k8s-uninstall-chart

Synopsis: make k8s-uninstall-chart

Hooks: k8s-pre-uninstall-chart, k8s-post-uninstall-chart

Variables:

Variable

Description

HELM_RELEASE

<Helm relase name> - default ‘test’

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

Teardown an instance (HELM_RELEASE) of a given Helm Chart from a specified Kubernetes Namespace, with a configurable set of parameters.

k8s-wait

Synopsis: make k8s-wait

Hooks: none

Variables:

Variable

Description

HELM_RELEASE

<Helm relase name> - default ‘test’

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

K8S_WAIT_LABEL_FILTER_ARGS

space separated label args - -l <label>=<value> - to match workloads to wait for

K8S_TIMEOUT

<timeout value> - defaults to 360s

Wait for the the Jobs and Pods deployed to a given KUBE_NAMESPACE. Will generate a log of Job/Pod logs and events if the wait times outs.

k8s-watch

Synopsis: make k8s-watch

Hooks: none

Variables:

Variable

Description

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

watch resources in KUBE_NAMESPACE using kubectl.

k8s-get

Synopsis: make k8s-get

Hooks: none

Variables:

Variable

Description

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

get resources in KUBE_NAMESPACE using kubectl.

k8s-describe

Synopsis: make k8s-describe

Hooks: none

Variables:

Variable

Description

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

describe resources in KUBE_NAMESPACE using kubectl.

k8s-podlogs

Synopsis: make k8s-podlogs

Hooks: none

Variables:

Variable

Description

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

Get Pod logs in KUBE_NAMESPACE using kubectl.

k8s-test

Synopsis: make k8s-test

Hooks: k8s-pre-test, k8s-post-test

Variables:

Variable

Description

K8S_TEST_TEST_COMMAND

<a command passed into the test Pod> - see K8S_TEST_TEST_COMMAND

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

K8S_TEST_RUNNER

<name of test runner container>

K8S_TEST_IMAGE_TO_TEST

<image to run the tests in>, it should have poetry if poetry.lock is present or uv if uv.lock is present for python

K8S_TIMEOUT

<timeout value> - defaults to 360s

PYTHON_RUNNER

<python executor> - defaults to empty, but could pass something like python -m

PYTHON_VARS_BEFORE_PYTEST

<environment variables defined before pytest in run> - default empty

PYTHON_VARS_AFTER_PYTEST

<additional switches passed to pytest> - default empty

K8S_TEST_WORKDIR

<working directory inside the pod for the test execution> - defaults to ‘.’ (CWD), can be overridden to /app or other

K8S_TEST_AUX_DIRS

<a list of extra directories to transfer to the test Pod> - default empty

Launch a K8S_TEST_RUNNER in the target Kubernetes Namespace, to run the tests against a deployed environment in the same way that python-test runs in a local context. The dependencies are installed from poetry.lock using poetry or uv.lock if present using uv, or from requirements.txt if it exists in the tests/ directory. Poetry installs use the current environment and include all dependency groups. If neither of these files are present, it will not install any dependencies. The default configuration runs pytest against the tests defined in ./tests. By default, this will pickup any pytest specific configuration set in pytest.ini, setup.cfg etc. located in ./tests. This test harness, is highly configurable, in that it is essentially a mechanism that enables remote execution of a oneline shell command, that is started in a copy of the current ./tests directory, and on completion, the contents of the ./build directory is returned. This is suited to the standard pytest runtime. The test runner pod is using the image defined in K8S_TEST_IMAGE_TO_TEST, which is expected to contain the necessary test dependencies and runtime tools, such as pytest and other python packages. It should have your dependency manager (poetry/pip/uv) installed. It defaults to the pipeline image built from the repository, i.e. $(CI_REGISTRY_IMAGE)/$(NAME):$(VERSION)-dev.c``$(CI_COMMIT_SHORT_SHA)`` in pipeline or last published repo image, i.e. $(CAR_OCI_REGISTRY_HOST)/$(NAME):$(VERSION), for local development. With this in mind, the default configuration for the oneline shellscript looks like: K8S_TEST_TEST_COMMAND ?= cd .. && $(PYTHON_VARS_BEFORE_PYTEST) $(K8S_TEST_PYTHON_RUNNER) pytest $(PYTHON_VARS_AFTER_PYTEST) ./tests | tee pytest.stdout; ## k8s-test test command to run in container NOTE the command steps back a directory so as to be outside of ./tests when k8s-test is running - this is to bring it into line with python-test behaviour. This can be replaced with essentially any executable application - for example, the one configured in Skampi is based on make:. K8S_TEST_TEST_COMMAND = make -s $(K8S_TEST_MAKE_PARAMS) $(K8S_TEST_TARGET) The test runner Pod is launched, and the contents of ./tests is piped in before the K8S_TEST_TEST_COMMAND is executed. This is expected to generate output into a ./build directory with a specifc set of files containing the test report output - the same as python-test.

k8s-test-runner

Synopsis: make k8s-test-runner

Hooks: k8s-pre-test, k8s-post-test

Variables:

Variable

Description

K8S_TEST_TEST_COMMAND

<a command passed into the test Pod> - see K8S_TEST_TEST_COMMAND

K8S_RUN_TEST_FOLDER

<folder from which to execute K8S_TEST_TEST_COMMAND> - defaults to ./

KUBE_NAMESPACE

<Kubernetes Namespace to deploy to> - default is project name (directory)

K8S_TEST_RUNNER

<name of test runner container>

K8S_TIMEOUT

<timeout value> - defaults to 360s

PYTHON_RUNNER

<python executor> - defaults to empty, but could pass something like python -m

PYTHON_VARS_BEFORE_PYTEST

<environment variables defined before pytest in run> - default empty

PYTHON_VARS_AFTER_PYTEST

<additional switches passed to pytest> - default empty

K8S_TEST_AUX_DIRS

<a list of extra directories to transfer to the test Pod> - default empty

Run the tests on the runner pod against a deployed environment in the same way that python-test runs in a local context. The default configuration runs pytest against the tests defined in ./tests. By default, this will pickup any pytest specific configuration set in pytest.ini, setup.cfg etc. located in ./tests. This test harness, is highly configurable, in that it is essentially a mechanism that enables remote execution of a oneline shell command, that is started in a copy of the current ./tests directory, and on completion, the contents of the ./build directory is returned. This is suited to the standard pytest runtime. With this in mind, the default configuration for the oneline shellscript looks like: K8S_TEST_TEST_COMMAND ?= cd .. && $(PYTHON_VARS_BEFORE_PYTEST) $(K8S_TEST_PYTHON_RUNNER) pytest $(PYTHON_VARS_AFTER_PYTEST) ./tests | tee pytest.stdout; ## k8s-test test command to run in container NOTE the command steps back a directory so as to be outside of ./tests when k8s-test is running - this is to bring it into line with python-test behaviour. This can be replaced with essentially any executable application - for example, the one configured in Skampi is based on make:. K8S_TEST_TEST_COMMAND = make -s $(K8S_TEST_MAKE_PARAMS) $(K8S_TEST_TARGET) This is expected to generate output into a ./build directory with a specifc set of files containing the test report output - the same as python-test.

k8s-info

Synopsis: make k8s-info

Hooks: none

Variables:

Variable

Description

KUBE_NAMESPACE

<Target Kubernetes namespace> - default is project name (directory)

CLUSTER_HEADLAMP_BASE_URL

<Headlamp base URL>

CLUSTER_HEADLAMP_CLUSTER_ID

<Headlamp cluster ID>

CLUSTER_KIBANA_BASE_URL

<Kibana base URL>

CLUSTER_KIBANA_VIEW_ID

<Kibana view ID>

CLUSTER_MONITORING_BASE_URL

<Monitoring cluster base URL>

CLUSTER_MONITOR

<Monitoring id for the cluster>

CLUSTER_DATACENTRE

<Cluster datacentre>

CLUSTER_ENVIRONMENT

<Cluster environment>

DESCRIPTION: Displays information about the specified Kubernetes namespace, including: - Pods and their associated OCI images - Installed Helm charts - Provides links to Grafana, Kibana and Kubernetes dashboards for that namespace. This information is especially useful in a CI environment where these details are crucial for debugging and monitoring. This target depends on k8s-namespace-info and k8s-namespace-links. Note: k8s-namespace-links is used in target k8s-install-chart and k8s-install-chart-car.