From 3227041386bf7c0e20f472527951ca3412fb6519 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Wed, 21 Jun 2023 18:59:15 +0000 Subject: [PATCH] e2e: add a test for using private registry with podman driver This PR adds an e2e test case that stands up a private docker registry and has a podman task run a container from an image in that private registry. Currently the podman driver only supports basic user:pass authentication embeded in the task. We can use this registry to iterate on future support for credentials helpers, etc. --- e2e/podman/input/auth_basic.hcl | 87 +++++++++++++ .../input/{podman_basic.hcl => redis.hcl} | 6 +- e2e/podman/input/registry.hcl | 122 ++++++++++++++++++ e2e/podman/podman_test.go | 58 ++++++--- 4 files changed, 251 insertions(+), 22 deletions(-) create mode 100644 e2e/podman/input/auth_basic.hcl rename e2e/podman/input/{podman_basic.hcl => redis.hcl} (77%) create mode 100644 e2e/podman/input/registry.hcl diff --git a/e2e/podman/input/auth_basic.hcl b/e2e/podman/input/auth_basic.hcl new file mode 100644 index 00000000000..28631ddf791 --- /dev/null +++ b/e2e/podman/input/auth_basic.hcl @@ -0,0 +1,87 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +# This job runs a podman task using a container stored in a private registry +# configured with basic authentication. The registry.hcl job should be running +# and healthy before running this job. The registry_address and registry_port +# HCL variables must be provided. + +variable "registry_address" { + type = string + description = "The HTTP address of the local registry" + default = "localhost" +} + +variable "registry_port" { + type = number + description = "The HTTP port of the local registry" +} + +variable "registry_username" { + type = string + description = "The Basic Auth username of the local registry" + default = "e2euser" +} + +variable "registry_password" { + type = string + description = "The Basic Auth password of the local registry" + default = "e2epassword" +} + +locals { + registry_auth = base64encode("${var.registry_username}:${var.registry_password}") +} + +job "auth_basic" { + type = "batch" + + constraint { + attribute = "${attr.kernel.name}" + value = "linux" + } + + group "basic" { + reschedule { + attempts = 0 + unlimited = false + } + + network { + mode = "host" + } + + task "echo" { + driver = "podman" + + # template { + # data = <:/docker.io/library/bash:private +#
:/docker.io/library/python:private +# +# Note that the
: is dynamic and can be found using NSD. +# Note that credentials are required (e.g. podman login), and are +# user: e2euser +# password: e2epassword + +job "registry" { + type = "service" + + constraint { + attribute = "${attr.kernel.name}" + value = "linux" + } + + group "registry-server" { + + reschedule { + attempts = 0 + unlimited = false + } + + network { + mode = "host" + port "registryhttp" {} + } + + service { + provider = "nomad" + name = "registry" + port = "registryhttp" + check { + name = "registry-http" + type = "http" + path = "/" + interval = "10s" + timeout = "3s" + } + } + + task "registry" { + driver = "podman" + + template { + data = <