diff --git a/Taskfile.yaml b/Taskfile.yaml index 190ee62..2df99dc 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -25,16 +25,13 @@ tasks: {{ if and (eq OS "linux") (ne (env "KUBECONFIG") "") }}Kubeconfig path: {{(env "KUBECONFIG")}}{{end}} cmds: - # Source the server.sh script to start docker - - '{{if eq OS "linux"}}source .github/scripts/server.sh{{end}}' + - '{{if eq OS "linux"}}source .github/scripts/server.sh{{end}}' # Source the server.sh script to start docker - # If KUBECONFIG env var is not set, set it to point to the Windows host - - '{{if eq OS "linux"}}[ -z "$KUBECONFIG" ] && echo "Set KUBECONFIG env var ==> {{.KUBE}}" && exit 1 \ - || k3d cluster create {{.CLUSTER_NAME}} --api-port 6443 -p 8080:80@loadbalancer --agents 2{{end}}' - - # If host is Windows, create cluster - - '{{if eq OS "windows"}}k3d cluster create {{.CLUSTER_NAME}} --api-port 6443 -p 8080:80@loadbalancer --agents 2{{end}}' + # If KUBECONFIG env var is not set, set it to point to the Windows host (or the host where the kubeconfig file is located) + - '{{if eq OS "linux"}}[ -z "$KUBECONFIG" ] && echo "Set KUBECONFIG env var ==> {{.KUBE}}" \ + && exit 1 || k3d cluster create {{.CLUSTER_NAME}} --api-port 6443 -p 8080:80@loadbalancer --agents 2{{end}}' + - '{{if eq OS "windows"}}k3d cluster create {{.CLUSTER_NAME}} --api-port 6443 -p 8080:80@loadbalancer --agents 2{{end}}' # If host is Windows, create cluster status: - k3d cluster list {{.CLUSTER_NAME}} # If cluster exists, skip the task silent: true @@ -51,6 +48,7 @@ tasks: cmds: - task: create - task: tf_init + - terraform -chdir='{{fromSlash "kube/bootstrap"}}' test - terraform -chdir='{{fromSlash "kube/bootstrap"}}' apply -auto-approve delete: diff --git a/docs/release_v0.1.0.md b/docs/release_v0.1.0.md deleted file mode 100644 index abab920..0000000 --- a/docs/release_v0.1.0.md +++ /dev/null @@ -1,60 +0,0 @@ -# - -This release focuses on Taskfile tasks and Go templating examples in tasks. - -## Features and Tools - -- `[Task](https://taskfile.dev/):` a cross-platform alternative to Make, supporting and showcasing `Go templates`. - -- `Terraform:` bootstraps the cluster and applies the ArgoCD helm chart. - -## Getting Started - -> **In this example, a WSL distro using a kubeconfig file located in the Windows user's home directory** - -1. Update the `KUBE` variable in [Taskfile.yml](../Taskfile.yaml) to match your path. - - ```yaml - env: - CLUSTER_NAME: kubepal - KUBE: export KUBECONFIG=/mnt/c/Users/{{.USER}}/.kube/config - ``` - -2. Update the `kube/bootstrap/backend.tf` to match `the path of your local kubeconfig file`: - - > Warning: Variables, locals, and functions may not be used here. - - ```hcl - - terraform { - backend "kubernetes" { - secret_suffix = "state" - - config_paths = [ - "/mnt/c/Users/devops/.kube/config", # WSL path - "c:\\Users\\devops\\.kube\\config" # PowerShell path - ] - } - } - - - ``` - -3. Run `task --list` in WSL or PowerShell to see the available tasks and the updated kubeconfig path. - - ```shell - $ task - task: Available tasks for this project: - - * create: Create and access a k3d cluster. - * delete: Delete cluster - * deploy: Bootstrap cluster and deploy apps - * tf_init: Initialize terraform - * run:connect: Get a shell to a running container - * run:pod: Create a temporary interactive pod, install some tools on it, and experiment - * run:start: Go template if statement - * run:test: Go template functions and examples using Powershell and Bash - ``` - -4. The `task deploy` command will create the cluster, deploy ArgoCD, and deploy the apps. -5. The `task delete` command will delete the cluster. diff --git a/kube/bootstrap/tests/argocd.tftest.hcl b/kube/bootstrap/tests/argocd.tftest.hcl index d4472aa..2826531 100644 --- a/kube/bootstrap/tests/argocd.tftest.hcl +++ b/kube/bootstrap/tests/argocd.tftest.hcl @@ -21,10 +21,23 @@ run "argocd_ingress" { command = plan - # Verify ArgoCD yaml manifest apiVersion + # Verify ArgoCD ingress apiVersion assert { condition = kubernetes_manifest.argocd_ingress.manifest.apiVersion == "networking.k8s.io/v1" error_message = "ArgoCD yaml manifest apiVersion did not match expected" } + # Verify ArgoCD ingress port + assert { + condition = kubernetes_manifest.argocd_ingress.manifest.spec.rules[0].http.paths[0].backend.service.port.number == 80 + error_message = "ArgoCD ingress port did not match expected" + } + + # Verify ArgoCD ingress path + assert { + condition = kubernetes_manifest.argocd_ingress.manifest.spec.rules[0].http.paths[0].path == "/argocd" + error_message = "ArgoCD ingress path did not match expected" + } + } +