diff --git a/.github/README.md b/.github/README.md deleted file mode 100644 index a4e3244..0000000 --- a/.github/README.md +++ /dev/null @@ -1,55 +0,0 @@ -

- -

- -**scaf fullstack template** provides developers and DevOps engineers with a -complete blueprint for a new project and streamlines the development experience -with Tilt. - -**scaf fullstack template** generates a new project structure with Kubernetes -manifests in three Kustomize layers for dev, sandbox, and production. A new -project contains the following: - -- Django backend -- Celery (optional) -- Next.js frontend (optional) - - Strawberry GraphQL (if frontend is chosen) - - Apollo Client (if frontend is chosen) - - _TODO: REST alternative to GraphQL_ -- Postgres database for local development -- CloudNativePG deployment for production -- Redis -- Mailhog -- ArgoCD -- Traefik -- Certmanger -- Certificates and Ingress Routes -- Kube Prometheus Stack -- Grafana Loki -- GitHub pipelines to build and push images, run security, formatting and - linting checks -- Terraform config to set up a k3s or Talos cluster on AWS -- Sentry (optional) - -## Installation - -To create a new project using this template, you first need to install `scaf`: - -``` -curl -sSL https://raw.githubusercontent.com/sixfeetup/scaf/main/install.sh | bash -``` - -The installation script will install kubectl, kind, and Tilt if it can't -be found on your system. - -## Creating a new project using this template - -NB: Before you continue, make sure that you have at least 5 to 10 GB of free -space available to Docker. Note that Docker Desktop on MacOS has its own -resource limits separate from the host. - -Run `scaf myproject https://github.com/getscaf/scaf-talos-template.git`, -answer all the questions, and you'll have your new project! - -Inside `myproject/README.md`, you will have more documentation explaining how to -use and configure your newly created project. diff --git a/.github/workflows/test-template.yaml b/.github/workflows/test-template.yaml deleted file mode 100644 index 9fa05bc..0000000 --- a/.github/workflows/test-template.yaml +++ /dev/null @@ -1,129 +0,0 @@ -name: Test template - -on: - pull_request: - schedule: - # Run daily at 2 AM UTC - - cron: '0 2 * * *' - workflow_dispatch: # Allow manual triggering - -jobs: - test-template: - runs-on: ubuntu-latest - environment: dev - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 'lts/*' - cache: 'npm' - cache-dependency-path: 'template/frontend/package*.json' - - - name: Install kind - shell: bash - run: | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64 - chmod +x ./kind - sudo mv ./kind /usr/local/bin/kind - - - name: Install Python dependencies - shell: bash - run: | - pip install copier black isort - - - name: Configure Git - shell: bash - run: | - git config --global user.email "test@example.com" - git config --global user.name "Template Test" - - - name: Test Template - shell: bash - env: - VCS_REF: ${{ github.head_ref || github.ref_name || github.sha }} - run: | - echo "Installing template from ${VCS_REF}" - copier copy \ - --trust \ - --defaults \ - --vcs-ref=${VCS_REF} \ - https://github.com/getscaf/scaf-talos-template.git test-project - - - name: Run lint and formatting checks - shell: bash - run: | - cd test-project - make check-lint-and-formatting - - - name: Run frontend lint and tests - shell: bash - run: | - cd test-project - make check-lint-and-test-frontend - - - name: Install Tilt - shell: bash - run: | - curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash - tilt version - - - name: Run Tilt CI - shell: bash - run: | - set -euo pipefail - cd test-project - tilt ci - - - name: Notify Slack on Success - if: success() && github.event_name == 'schedule' - uses: slackapi/slack-github-action@v2.1.1 - with: - webhook: ${{ secrets.SLACK_WEBHOOK_URL }} - webhook-type: incoming-webhook - payload: | - text: "Daily template test completed successfully! ✅" - blocks: - - type: "section" - text: - type: "mrkdwn" - text: "Daily template test completed successfully! ✅" - - type: "section" - fields: - - type: "mrkdwn" - text: "*Repository*: ${{ github.repository }}" - - type: "mrkdwn" - text: > - *Run Details*: - <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Logs> - - - name: Notify Slack on Failure - if: failure() && github.event_name == 'schedule' - uses: slackapi/slack-github-action@v2.1.1 - with: - webhook: ${{ secrets.SLACK_WEBHOOK_URL }} - webhook-type: incoming-webhook - payload: | - text: "Daily template test failed! ❌" - blocks: - - type: "section" - text: - type: "mrkdwn" - text: "Daily template test failed! ❌" - - type: "section" - text: - type: "mrkdwn" - text: "Please check the workflow logs for more information." - - type: "section" - fields: - - type: "mrkdwn" - text: "*Repository*: ${{ github.repository }}" - - type: "mrkdwn" - text: > - *Run Details*: - <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Logs> diff --git a/README.md b/README.md new file mode 100644 index 0000000..4320491 --- /dev/null +++ b/README.md @@ -0,0 +1,130 @@ +

+ +

+ +**scaf-talos-template** provides DevOps engineers and infrastructure teams with a complete blueprint for deploying production-ready Talos Linux Kubernetes clusters on AWS. + +This template generates infrastructure-as-code for a secure, immutable Kubernetes cluster using Talos Linux. A new project contains the following: + +- **Talos Linux v1.12.1** - Immutable, secure Kubernetes OS +- **Terraform/OpenTofu** - Infrastructure provisioning for AWS +- **AWS Infrastructure** - VPC, EC2, security groups, load balancers, Route53 +- **Multi-Environment Support** - Sandbox, staging, and production configurations +- **Bootstrap Scripts** - Automated Talos cluster initialization +- **GitHub Actions** - Infrastructure validation and security scanning +- **Comprehensive Documentation** - Deployment guides and architecture diagrams + +## What is Talos Linux? + +Talos Linux is a modern, minimal Linux distribution designed specifically for running Kubernetes: + +- **Immutable** - No SSH access, configuration via API only +- **Secure** - Minimal attack surface, all management via encrypted API +- **Kubernetes-Native** - Built exclusively for Kubernetes workloads +- **API-Driven** - All operations performed via declarative configuration + +## Installation + +To create a new project using this template, you first need to install `scaf`: + +```bash +curl -sSL https://raw.githubusercontent.com/sixfeetup/scaf/main/install.sh | bash +``` + +## Creating a new project using this template + +Run the following command to create a new project: + +```bash +# If you have the template checked out locally: +scaf myproject ./scaf-talos-template + +# Or use the GitHub URL directly: +scaf myproject https://github.com/getscaf/scaf-talos-template.git +``` + +Answer all the questions, and you'll have your new Talos cluster infrastructure project! + +After creating the project, you need to bootstrap the infrastructure. + +First, make sure you're logged in to AWS: + +```bash +export AWS_PROFILE=profile && aws sso login +``` + +Then proceed with the infrastructure setup: + +```bash +# 1. Create the S3 backend for Terraform state +cd myproject/terraform/bootstrap +tofu init && tofu plan -out=tfplan.out && tofu apply tfplan.out + +# 2. Deploy the infrastructure - sandbox environment +cd ../sandbox +tofu init && tofu plan -out=tfplan.out && tofu apply tfplan.out + +# 3. Bootstrap Talos cluster +cd ../../bootstrap-cluster +export ENV=sandbox +task talos:bootstrap + +# 4. Access your cluster +eval $(task talos:kubeconfig) +kubectl get nodes +``` + +**Note:** The sandbox environment creates a **1-node cluster** for development and testing. For staging and production environments with **3-node clusters**, use: + +```bash +# Deploy staging (3 nodes) +cd terraform/staging +tofu init && tofu plan -out=tfplan.out && tofu apply tfplan.out +cd ../../bootstrap-cluster +export ENV=staging +task talos:bootstrap + +# Deploy production (3 nodes) +cd ../terraform/production +tofu init && tofu plan -out=tfplan.out && tofu apply tfplan.out +cd ../../bootstrap-cluster +export ENV=production +task talos:bootstrap +``` + +Inside `myproject/docs/`, you will find comprehensive documentation for: +- Deploying infrastructure to AWS +- Bootstrapping the Talos cluster +- Managing cluster credentials +- Architecture diagrams + +## Requirements + +- AWS account with appropriate credentials +- Terraform/OpenTofu (v1.6+) +- talosctl CLI +- kubectl CLI +- Task runner + +See the generated documentation for detailed prerequisites. + +## Removing an Environment + +To completely remove an environment and all its resources: + + +```bash +# 1. Destroy the infrastructure +cd myproject/terraform/sandbox # or staging, production +tofu destroy + +# 2. Clean up local configuration files +cd ../../bootstrap-cluster/sandbox # or staging, production +rm -f talosconfig kubeconfig controlplane.yaml + +# 3. (Optional) Remove secrets from AWS Secrets Manager +aws secretsmanager delete-secret --secret-id sandbox_talosconfig_yaml --force-delete-without-recovery +aws secretsmanager delete-secret --secret-id sandbox_kubeconfig_yaml --force-delete-without-recovery +``` + +For complete removal instructions, including how to destroy the S3 backend, see the [Deployment Documentation](myproject/docs/deployment.md). diff --git a/copier.yml b/copier.yml index a614cbb..0988929 100644 --- a/copier.yml +++ b/copier.yml @@ -132,33 +132,3 @@ copier__aws_account_id: "AWS account ID cannot be empty." {% endif %} -copier__operating_system: - type: str - default: "talos" - choices: - talos: "talos" - help: "Deploy Kubernetes on Talos Linux?" - -copier__repo_url: - type: str - default: "git@github.com:organization_name/{{ copier__project_slug }}.git" - help: "The URL of the repository." - validator: >- - {% if not copier__repo_url.startswith("git@") or not ":" in copier__repo_url or not "/" in copier__repo_url.split(":")[1] or not ".git" in copier__repo_url %} - Value must follow the format git@provider:orgname/repo.git - {% endif %} - -copier__source_control_provider: - type: str - when: false - default: "{{ copier__repo_url.split('@')[1].split(':')[0] }}" - -copier__source_control_organization_slug: - type: str - when: false - default: "{{ copier__repo_url.split(':')[1].split('/')[0] }}" - -copier__repo_name: - type: str - when: false - default: "{{ copier__repo_url.split(':')[1].split('/')[1].replace('.git', '') }}" diff --git a/issues.md b/issues.md deleted file mode 100644 index 919cfc6..0000000 --- a/issues.md +++ /dev/null @@ -1,54 +0,0 @@ -# issue log -1. after `./scaf