-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
83 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
|
||
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. |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,17 @@ | ||
# Kubepal | ||
|
||
A local [`k3d`](https://k3d.io) cluster setup, ready to deploy your apps, pre-packaged with a few useful tools. | ||
Designed to be used with both, WSL and Powershell simultaneously. | ||
`Kubepal` is a local k3d cluster setup designed for cluster configuration development and app deployment experimentation. | ||
|
||
- [Task](https://taskfile.dev/) used as a `make` alternative, supports Go templates and is cross-platform. | ||
Key features: | ||
|
||
- Terraform used to deploy the ArgoCD helm chart after the cluster is up and running. | ||
- ✅ Disposable and Quick-to-Use: Create and delete the cluster set up with a single command. | ||
|
||
GitOps focused, will try to replicate an easy to use, temporary local cluster setup for development/testing purposes. | ||
- ✅ GitOps Ready: Replicate GitOps practices in a local environment. | ||
|
||
A tools and code snippets collection for future reference. | ||
- ✅ Testing Ground for Tools: Explore and experiment with various tools and their configurations. | ||
|
||
## Getting started | ||
Releases: | ||
|
||
- On [`Taskfile.yml`](./Taskfile.yaml), update the KUBE variable ( if necessary ) to match your WSL path to kubeconfig file on Windows host: | ||
- Each release represents a snapshot of tools and their configurations as described in the release docs "Focus" section. | ||
|
||
```yml | ||
env: | ||
CLUSTER_NAME: kubepal | ||
KUBE: export KUBECONFIG=/mnt/c/Users/{{.USER}}/.kube/config # WSL path to kubeconfig file on Windows host | ||
``` | ||
- Update the [`config_paths`](./kube/bootstrap/backend.tf) list to match your local `kubeconfig file` path: | ||
|
||
```hcl | ||
// Warning: Variables, locals and functions may not be used here. | ||
config_paths = [ | ||
"/mnt/c/Users/devops/.kube/config", | ||
"c:\\Users\\devops\\.kube\\config" | ||
] | ||
``` | ||
|
||
- Run `task --list` on WSL or Powershell to see the available tasks and the updated `kubeconfig` path. | ||
|
||
```bash | ||
task: Available tasks for this project: | ||
* create: Create and access a k3d cluster. | ||
If operating on WSL, the KUBECONFIG env var will point to the Windows host. | ||
Kubeconfig path: /mnt/c/Users/devops/.kube/config | ||
* delete: Delete cluster | ||
* deploy: Bootstrap cluster and deploy apps | ||
* tf_init: Initialize terraform | ||
* run:clean: Clean up /.kube/config | ||
* run:connect: Get a shell to a running container | ||
* run:path: Convert a string from / path format to \ | ||
* run:start: Go template if statement | ||
* run:temp_pod: Create a temporary interactive pod, install some tools on it, and experiment | ||
* run:test: Go template functions and examples using Powershell and Bash | ||
``` | ||
|
||
- `task deploy` will perform all steps to create the cluster, deploy ArgoCD and deploy the apps. | ||
|
||
- `task delete` will delete the cluster. | ||
- [x] [v0.1.0](/docs/release_v0.1.0.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,36 @@ | ||
version: "3" | ||
|
||
tasks: | ||
clean: | ||
desc: "Clean up /.kube/config" | ||
cmds: | ||
- :> $KUBECONFIG | ||
env: | ||
POD_NAME: kubepal-tester | ||
|
||
temp_pod: | ||
tasks: | ||
pod: | ||
desc: "Create a temporary interactive pod, install some tools on it, and experiment " | ||
cmds: | ||
- kubectl run -i --tty tester --image debian | ||
- kubectl run -i --tty {{.POD_NAME}} --image debian | ||
status: | ||
- kubectl get pods {{.POD_NAME}} # If pod exists, skip the task | ||
|
||
connect: | ||
desc: "Get a shell to a running container" | ||
cmds: | ||
- task: pod | ||
- kubectl exec --stdin --tty {{.POD_NAME}} -- /bin/bash | ||
vars: | ||
POD_NAME: | ||
sh: kubectl get po | grep $(yq '.metadata.name' text/deploy.yml) | awk '{print $1}' | ||
|
||
test: | ||
desc: "Go template functions and examples using Powershell and Bash" | ||
desc: "Go template functions examples using Powershell and Bash" | ||
cmds: | ||
- '{{if eq OS "windows"}}powershell "Get-ComputerInfo | select WindowsProductName"{{else}}cat /etc/os-release{{end}}' | ||
|
||
- '{{ if and (eq OS "windows") (eq (env "KUBECONFIG") "") }} echo "OS is windows and KUBECONFIG var is empty" {{end}}' | ||
silent: true | ||
|
||
start: | ||
desc: "Go template if statement" | ||
desc: "Start Docker Desktop on Windows" | ||
cmds: | ||
# Run a command if OS is windows | ||
- '{{if eq OS "windows"}}powershell Start-Process "\"C:\ProgramData\Microsoft\Windows\Start Menu\Docker Desktop"\"{{end}}' | ||
silent: true | ||
|
||
path: | ||
desc: "Convert a string from / path format to \\" | ||
cmds: | ||
# Run a command if OS is windows | ||
- echo '{{fromSlash "kube/bootstrap/"}}' | ||
# If OS is linux, echo a message | ||
- '{{if eq OS "linux"}}echo "This is a Windows only command"{{end}}' | ||
silent: true |