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

migrate argocd to imagetest #2372

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 59 additions & 48 deletions images/argocd/tests/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
helm = { source = "hashicorp/helm" }
oci = { source = "chainguard-dev/oci" }
imagetest = { source = "chainguard-dev/imagetest" }
}
}

Expand All @@ -18,57 +18,68 @@ data "oci_string" "ref" {
input = each.value
}

resource "helm_release" "argocd" {
name = "argocd"
data "imagetest_inventory" "this" {}

repository = "https://argoproj.github.io/argo-helm"
chart = "argo-cd"
resource "imagetest_harness_k3s" "this" {
name = "cert-manager"
inventory = data.imagetest_inventory.this
}

namespace = "argocd"
create_namespace = true
module "install" {
source = "../../../tflib/imagetest/helm"

# The argocd helm chart installs CRDs from the `templates/` directory,
# and the default value (`false`) conflicts with the providers
# assumption of them being in `crds/`
skip_crds = true
chart = "argo-cd"
namespace = "argocd"
repo = "https://argoproj.github.io/argo-helm"

values = [
jsonencode({
image = {
tag = data.oci_string.ref["server"].pseudo_tag
repository = data.oci_string.ref["server"].registry_repo
values = {
config = {
params = {
}
repoServer = {
image = {
tag = data.oci_string.ref["repo-server"].pseudo_tag
repository = data.oci_string.ref["repo-server"].registry_repo
}
}
image = {
tag = data.oci_string.ref["server"].pseudo_tag
repository = data.oci_string.ref["server"].registry_repo
}
repoServer = {
image = {
tag = data.oci_string.ref["repo-server"].pseudo_tag
repository = data.oci_string.ref["repo-server"].registry_repo
}
# redis-ha = {
# enabled = true
# # image = {
# # repository = "cgr.dev/chainguard/redis"
# # tag = "latest"
# # }
# haproxy = {
# image = {
# repository = "k3d-k3d.localhost:5005/cg/haproxy"
# tag = "2.8@sha256:d9a67188af5cb89f5398399f704e75079a25e241481d22205de38637bd9052c0"
# }
#
# containerSecurityContext = {
# capabilities = {
# add = ["NET_BIND_SERVICE"]
# }
# }
# }
# }
}),
]
}
}
}

# module "helm_cleanup" {
# source = "../../../tflib/helm-cleanup"
# name = helm_release.argocd.id
# namespace = helm_release.argocd.namespace
# }
resource "imagetest_feature" "basic" {
harness = imagetest_harness_k3s.this
name = "Basic"
description = "Basic functionality of the argocd helm chart."

steps = [
{
name = "Helm install"
cmd = module.install.install_cmd
},
{
name = "Deploy the guestbook"
cmd = <<EOF
apk add argo-cd
args="--port-forward --port-forward-namespace=argocd"
password=$(kubectl get secrets -n argocd argocd-initial-admin-secret -ojsonpath='{.data.password}' | base64 -d -)
argocd login $args --password $password --username admin
argocd app create guestbook $args \
--repo https://github.com/argoproj/argocd-example-apps.git \
joshrwolf marked this conversation as resolved.
Show resolved Hide resolved
--path guestbook \
--dest-server https://kubernetes.default.svc \
--dest-namespace default

argocd app sync guestbook $args --timeout "120"
argocd app wait guestbook $args --timeout "120"
EOF
},
]

labels = {
type = "k8s"
}
}
Loading