diff --git a/test/test-cloud/.gitignore b/test/test-cloud/.gitignore new file mode 100644 index 0000000..f54d81a --- /dev/null +++ b/test/test-cloud/.gitignore @@ -0,0 +1,6 @@ +.wildcloud +secrets.yaml +.bots/*/sessions +backup/ +.working +setup/cluster-nodes/generated/talosconfig diff --git a/test/test-cloud/README.md b/test/test-cloud/README.md new file mode 100644 index 0000000..89532d2 --- /dev/null +++ b/test/test-cloud/README.md @@ -0,0 +1,23 @@ +# Your Wild Cloud + +## One-time Setup + +Congratulations! Everything you need for setting up and managing your wild-cloud is in this directory. + +Just run: + +```bash +wild-setup +``` + +## Using your wild-cloud + +### Installing Wild Cloud apps + +```bash +wild-apps-list +wild-app-fetch +wild-app-config +wild-app-deploy +# Optional: Check in app templates. +``` diff --git a/test/test-cloud/apps/README.md b/test/test-cloud/apps/README.md new file mode 100644 index 0000000..89592d8 --- /dev/null +++ b/test/test-cloud/apps/README.md @@ -0,0 +1,48 @@ +# My Wild Cloud Apps + +This directory contains the definitions for _your_ wild-cloud apps. You can change them however you like. You should keep them all in git and make commits anytime you change something. Some `wild` commands will overwrite files in your app directory (like when you are updating apps, or updating your configuration) so you'll want to review any changes made to your files after using them using `git`. + +## Usage + +To list all available apps: + +```bash +wild-cloud-app-list +``` + +### App Workflow + +The Wild Cloud app workflow consists of three steps: + +1. **Fetch** - Download raw app templates to cache +2. **Config** - Apply your local configuration to templates +3. **Deploy** - Deploy configured app to Kubernetes + +### Commands + +To fetch an app template to cache: + +```bash +wild-app-fetch +``` + +To apply your configuration to a cached app (automatically fetches if not cached): + +```bash +wild-app-config +``` + +To deploy a configured app to Kubernetes: + +```bash +wild-app-deploy +``` + +### Quick Setup + +For a complete app setup and deployment: + +```bash +wild-app-config # Fetches if needed, then configures +wild-app-deploy # Deploys to Kubernetes +``` diff --git a/test/test-cloud/config.yaml b/test/test-cloud/config.yaml new file mode 100644 index 0000000..219bc55 --- /dev/null +++ b/test/test-cloud/config.yaml @@ -0,0 +1,8 @@ +operator: + email: test@domain.tld +cloud: + baseDomain: domain.tld + domain: cloud.domain.tld + internalDomain: internal.cloud.domain.tld +cluster: + name: cloud-domain-tld diff --git a/test/test-cloud/env.sh b/test/test-cloud/env.sh new file mode 100644 index 0000000..f03054f --- /dev/null +++ b/test/test-cloud/env.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +# Set the WC_HOME environment variable to this script's directory. +# This variable is used consistently across the Wild Config scripts. +export WC_HOME="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" + +# Add bin to path first so wild-config is available +export PATH="$WC_HOME/bin:$PATH" + +# Install kubectl +if ! command -v kubectl &> /dev/null; then + echo "Installing kubectl" + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256" + echo "$(cat kubectl.sha256) kubectl" | sha256sum --check + sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl + rm kubectl kubectl.sha256 + echo "kubectl installed successfully." +fi + +# Install talosctl +if ! command -v talosctl &> /dev/null; then + echo "Installing talosctl" + curl -sL https://talos.dev/install | sh + if [ $? -ne 0 ]; then + echo "Error installing talosctl. Please check the installation script." + exit 1 + fi + echo "talosctl installed successfully." +fi + +# Check if gomplate is installed +if ! command -v gomplate &> /dev/null; then + echo "Installing gomplate" + curl -sSL https://github.com/hairyhenderson/gomplate/releases/latest/download/gomplate_linux-amd64 -o $HOME/.local/bin/gomplate + chmod +x $HOME/.local/bin/gomplate + echo "gomplate installed successfully." +fi + +# Install kustomize +if ! command -v kustomize &> /dev/null; then + echo "Installing kustomize" + curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash + mv kustomize $HOME/.local/bin/ + echo "kustomize installed successfully." +fi + +## Install yq +if ! command -v yq &> /dev/null; then + echo "Installing yq" + VERSION=v4.45.4 + BINARY=yq_linux_amd64 + wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - | tar xz + mv ${BINARY} $HOME/.local/bin/yq + chmod +x $HOME/.local/bin/yq + rm yq.1 + echo "yq installed successfully." +fi + +KUBECONFIG=~/.kube/config +export KUBECONFIG + +# Use cluster name as both talos and kubectl context name +CLUSTER_NAME=$(wild-config cluster.name) +if [ -z "${CLUSTER_NAME}" ] || [ "${CLUSTER_NAME}" = "null" ]; then + echo "Error: cluster.name not set in config.yaml" +else + KUBE_CONTEXT="admin@${CLUSTER_NAME}" + CURRENT_KUBE_CONTEXT=$(kubectl config current-context) + if [ "${CURRENT_KUBE_CONTEXT}" != "${KUBE_CONTEXT}" ]; then + if kubectl config get-contexts | grep -q "${KUBE_CONTEXT}"; then + echo "Switching to kubernetes context ${KUBE_CONTEXT}" + else + echo "WARNING: Context ${KUBE_CONTEXT} does not exist." + # kubectl config set-context "${KUBE_CONTEXT}" --cluster="${CLUSTER_NAME}" --user=admin + fi + fi +fi