diff --git a/docs-website/static/docs/walkthroughs/k3s_init.html b/docs-website/static/docs/walkthroughs/k3s_init.html new file mode 100644 index 0000000000..fdc2f69623 --- /dev/null +++ b/docs-website/static/docs/walkthroughs/k3s_init.html @@ -0,0 +1,99 @@ + + + + + + +
+? Deploy this Zarf package? (y/N) Yes
+
+───────────────────────────────────────────────────────────────────────────────────────
+name: k3s
+only:
+  localOS: linux
+  cluster:
+    architecture: amd64
+actions:
+  onDeploy:
+     defaults:
+       maxRetries: 5
+     before:
+     - maxRetries: 0
+       cmd: ./zarf internal is-valid-hostname
+     - cmd: "[ -e /etc/redhat-release ] && systemctl disable firewalld --now || echo ''"
+     after:
+     - cmd: systemctl daemon-reload
+     - cmd: systemctl enable k3s
+     - cmd: systemctl start k3s
+files:
+- source: packages/distros/k3s/common/zarf-clean-k3s.sh
+  target: /opt/zarf/zarf-clean-k3s.sh
+  executable: true
+- source: packages/distros/k3s/common/k3s.service
+  target: /etc/systemd/system/k3s.service
+  symlinks:
+  - /etc/systemd/system/multi-user.target.wants/k3s.service
+- source: https://github.com/k3s-io/k3s/releases/download/v1.24.1+k3s1/k3s
+  shasum: ca398d82fee8f9f52b05fb184582054be3c0285a1b9e8fb5c7b9a91448a
+  target: /usr/sbin/k3s
+  executable: true
+  symlinks:
+  - /usr/sbin/kubctl
+  - /usr/sbin/ctr
+  - /usr/sbin/crictl
+- source: https://github.com/k3s-io/k3s/releases/download/v1.24.1+k3s1/k3s-airgap-images-amd64.tar.zst
+  shasum: 6736bf9fa4d5754d60b0508bafb2f888a70cb99a203a3a1617a919ca4ee74034
+  target: /var/lib/rancher/k3s/agent/images/k3s.tar.zst
+
+*** REQUIRES ROOT *** Install K3s, certified Kubernetes distribution built for IoT & Edge computing
+K3s provides the cluster need for Zarf running in Appliance Mode as well as can host a low-resource
+Gitops Service if not using an existing Kubernetes platform.
+
+? Deploy the k3s component? (y/N) Yes
+───────────────────────────────────────────────────────────────────────────────────────
+
+
+ + diff --git a/docs-website/static/docs/walkthroughs/zarf_init.html b/docs-website/static/docs/walkthroughs/zarf_init.html new file mode 100644 index 0000000000..25f24d1afd --- /dev/null +++ b/docs-website/static/docs/walkthroughs/zarf_init.html @@ -0,0 +1,423 @@ + + + + + + +
+$ zarf init
+Using config file /Users/josimoore/Desktop/projects/zarf/zarf-config.toml + +Saving log file to +/var/folders/gb/qfjdrlp52_v87bj_2rfzqls00000gn/T/zarf-2023-03-28-08-39-23-314846914.log + + • Loading Zarf Package /Users/josimoore/.zarf-cache/zarf-init-arm64-v0.25.0.tar.zst + • Loading Zarf Package /Users/josimoore/.zarf-cache/zarf-init-arm64-v0.25.0.tar.zst + +kind: ZarfInitConfig +metadata: + name: init + description: Used to establish a new Zarf cluster + architecture: arm64 +build: + terminal: fv-az442-536 + user: runner + architecture: arm64 + timestamp: Tue, 21 Mar 2023 23:50:40 +0000 + version: v0.25.0 + migrations: + - scripts-to-actions +components: +- name: zarf-injector + description: | + Bootstraps a Kubernetes cluster by cloning a running pod in the cluster and hosting the registry image. + Removed and destroyed after the Zarf Registry is self-hosting the registry image. + required: true + cosignKeyPath: cosign.pub + files: + - source: sget://defenseunicorns/zarf-injector:arm64-2023-02-09 + target: "###ZARF_TEMP###/zarf-injector" + executable: true +- name: zarf-seed-registry + description: | + Deploys the Zarf Registry using the registry image provided by the Zarf Injector. + required: true + charts: + - name: docker-registry + releaseName: zarf-docker-registry + version: 1.0.0 + namespace: zarf + valuesFiles: + - packages/zarf-registry/registry-values.yaml + - packages/zarf-registry/registry-values-seed.yaml + localPath: packages/zarf-registry/chart +- name: zarf-registry + description: | + Updates the Zarf Registry to use the self-hosted registry image. + Serves as the primary docker registry for the cluster. + required: true + charts: + - name: docker-registry + releaseName: zarf-docker-registry + version: 1.0.0 + namespace: zarf + valuesFiles: + - packages/zarf-registry/registry-values.yaml + localPath: packages/zarf-registry/chart + manifests: + - name: registry-connect + namespace: zarf + files: + - packages/zarf-registry/connect.yaml + - name: kep-1755-registry-annotation + namespace: zarf + files: + - packages/zarf-registry/configmap.yaml + images: + - registry:2.8.1 +- name: zarf-agent + description: | + A Kubernetes mutating webhook to enable automated URL rewriting for container + images and git repository references in Kubernetes manifests. This prevents + the need to manually update URLs from their original sources to the Zarf-managed + docker registry and git server. + required: true + actions: + onCreate: + before: + - cmd: make init-package-local-agent AGENT_IMAGE="agent:v0.25.0" + manifests: + - name: zarf-agent + namespace: zarf + files: + - packages/zarf-agent/manifests/service.yaml + - packages/zarf-agent/manifests/secret.yaml + - packages/zarf-agent/manifests/deployment.yaml + - packages/zarf-agent/manifests/webhook.yaml + images: + - ghcr.io/defenseunicorns/zarf/agent:v0.25.0 +- name: logging + description: | + Deploys the Promtail Grafana & Loki (PGL) stack. + Aggregates logs from different containers and presents them in a web dashboard. + Recommended if no other logging stack is deployed in the cluster. + charts: + - name: loki-stack + releaseName: zarf-loki-stack + url: https://grafana.github.io/helm-charts + version: 2.9.9 + namespace: zarf + valuesFiles: + - packages/logging-pgl/pgl-values.yaml + manifests: + - name: logging-connect + namespace: zarf + files: + - packages/logging-pgl/connect.yaml + images: + - docker.io/grafana/promtail:2.7.2 + - grafana/grafana:8.3.5 + - grafana/loki:2.6.1 + - quay.io/kiwigrid/k8s-sidecar:1.19.2 +- name: git-server + description: | + Deploys Gitea to provide git repositories for Kubernetes configurations. + Required for GitOps deployments if no other git server is available. + actions: + onDeploy: + after: + - maxTotalSeconds: 60 + maxRetries: 3 + cmd: ./zarf internal create-read-only-gitea-user + charts: + - name: gitea + releaseName: zarf-gitea + url: https://dl.gitea.io/charts + version: 7.0.4 + namespace: zarf + valuesFiles: + - packages/gitea/gitea-values.yaml + manifests: + - name: git-connect + namespace: zarf + files: + - packages/gitea/connect.yaml + images: + - gitea/gitea:1.18.5 +variables: +- name: K3S_ARGS + description: Arguments to pass to K3s + default: --disable traefik +- name: REGISTRY_EXISTING_PVC + description: "Optional: Use an existing PVC for the registry instead of creating a new one. If this is set, the REGISTRY_PVC_SIZE variable will be ignored." +- name: REGISTRY_PVC_SIZE + description: The size of the persistent volume claim for the registry + default: 20Gi +- name: REGISTRY_CPU_REQ + description: The CPU request for the registry + default: 100m +- name: REGISTRY_MEM_REQ + description: The memory request for the registry + default: 256Mi +- name: REGISTRY_CPU_LIMIT + description: The CPU limit for the registry + default: "3" +- name: REGISTRY_MEM_LIMIT + description: The memory limit for the registry + default: 2Gi +- name: REGISTRY_HPA_MIN + description: The minimum number of registry replicas + default: "1" +- name: REGISTRY_HPA_MAX + description: The maximum number of registry replicas + default: "5" +- name: REGISTRY_HPA_ENABLE + description: Enable the Horizontal Pod Autoscaler for the registry + default: "true" +- name: GIT_SERVER_EXISTING_PVC + description: "Optional: Use an existing PVC for the git server instead of creating a new one. If this is set, the GIT_SERVER_PVC_SIZE variable will be ignored." +- name: GIT_SERVER_PVC_SIZE + description: The size of the persistent volume claim for git server + default: 10Gi +- name: GIT_SERVER_CPU_REQ + description: The CPU request for git server + default: 200m +- name: GIT_SERVER_MEM_REQ + description: The memory request for git server + default: 512Mi +- name: GIT_SERVER_CPU_LIMIT + description: The CPU limit for git server + default: "3" +- name: GIT_SERVER_MEM_LIMIT + description: The memory limit for git server + default: 2Gi +constants: +- name: AGENT_IMAGE + value: agent:v0.25.0 +This package has 9 artifacts with software bill-of-materials (SBOM) included. You can view them now +in the zarf-sbom folder in this directory or to go directly to one, open this in your browser: +/Users/josimoore/Desktop/projects/zarf/zarf-sbom/sbom-viewer-docker.io_grafana_promtail_2.7.2.html + +* This directory will be removed after package deployment. + +? Deploy this Zarf package? (y/N) Yes + +─────────────────────────────────────────────────────────────────────────────────────── +name: k3s +only: + localOS: linux + cluster: + architecture: amd64 +actions: + onDeploy: + defaults: + maxRetries: 5 + before: + - maxRetries: 0 + cmd: ./zarf internal is-valid-hostname + - cmd: "[ -e /etc/redhat-release ] && systemctl disable firewalld --now || echo ''" + after: + - cmd: systemctl daemon-reload + - cmd: systemctl enable k3s + - cmd: systemctl start k3s +files: +- source: packages/distros/k3s/common/zarf-clean-k3s.sh + target: /opt/zarf/zarf-clean-k3s.sh + executable: true +- source: packages/distros/k3s/common/k3s.service + target: /etc/systemd/system/k3s.service + symlinks: + - /etc/systemd/system/multi-user.target.wants/k3s.service +- source: https://github.com/k3s-io/k3s/releases/download/v1.24.1+k3s1/k3s + shasum: ca398d82fee8f9f52b05fb184582054be3c0285a1b9e8fb5c7b9a91448a + target: /usr/sbin/k3s + executable: true + symlinks: + - /usr/sbin/kubctl + - /usr/sbin/ctr + - /usr/sbin/crictl +- source: https://github.com/k3s-io/k3s/releases/download/v1.24.1+k3s1/k3s-airgap-images-amd64.tar.zst + shasum: 6736bf9fa4d5754d60b0508bafb2f888a70cb99a203a3a1617a919ca4ee74034 + target: /var/lib/rancher/k3s/agent/images/k3s.tar.zst + +*** REQUIRES ROOT *** Install K3s, certified Kubernetes distribution built for IoT & Edge computing +K3s provides the cluster need for Zarf running in Appliance Mode as well as can host a low-resource +Gitops Service if not using an existing Kubernetes platform. + +? Deploy the k3s component? (y/N) No + +─────────────────────────────────────────────────────────────────────────────────────── + +name: logging +charts: +- name: loki-stack + releaseName: zarf-loki-stack + url: https://grafana.github.io/helm-charts + version: 2.9.9 + namespace: zarf + valuesFiles: + - packages/logging-pgl/pgl-values.yaml +manifests: +- name: logging-connect + namespace: zarf + files: + - packages/logging-pgl/connect.yaml +images: +- docker.io/grafana/promtail:2.7.2 +- grafana/grafana:8.3.5 +- grafana/loki:2.6.1 +- quay.io/kiwigrid/k8s-sidecar:1.19.2 + +Deploys the Promtail Grafana & Loki (PGL) stack. Aggregates logs from different containers and +presents them in a web dashboard. Recommended if no other logging stack is deployed in the cluster. + +? Deploy the logging component? (y/N) No + +─────────────────────────────────────────────────────────────────────────────────────── + +name: git-server +actions: + onDeploy: + after: + - maxTotalSeconds: 60 + maxRetries: 3 + cmd: ./zarf internal create-read-only-gitea-user +charts: +- name: gitea + releaseName: zarf-gitea + url: https://d1.gitea.io/charts + version: 7.0.4 + namespace: zarf + valuesFiles: + - packages/gitea/gitea-values.yaml +manifests: +- name: git-connect + namespace: zarf + files: + - packages/gitea/connect.yaml +images: +- gitea/gitea:1.18.5 + +Deploys Gitea to provide git repositories for Kubernetes configurations. Required for GitOps +deployments if no other git server is available. +? Deploy the git-server component? (y/N) No + +
+ + 📦 ZARF-INJECTOR COMPONENT + + +
+ + • Copying 1 files + • Copying 1 files + • Gathering cluster information + • Gathering cluster information + • Attempting to bootstrap the seed image into the cluster + • Attempting to bootstrap the seed image into the cluster + +
+ + 📦 ZARF-SEED-REGISTRY COMPONENT + + +
+ + • Loading the Zarf State from the Kubernetes cluster + • Loading the Zarf State from the Kubernetes cluster + • Processing helm chart docker-registry:1.0.0 from Zarf-generated helm chart + • Processing helm chart docker-registry:1.0.0 from Zarf-generated helm chart + +
+ + 📦 ZARF-REGISTRY COMPONENT + + +
+ + • Opening tunnel 62270 -> 5000 for svc/zarf-docker-registry in namespace zarf + • Creating port forwarding tunnel at http://127.0.0.1:62270/v2/_catalog + • Storing images in the zarf registry + • Storing images in the zarf registry + • Processing helm chart docker-registry:1.0.0 from Zarf-generated helm chart + • Processing helm chart docker-registry:1.0.0 from Zarf-generated helm chart + • Starting helm chart generation registry-connect + • Starting helm chart generation registry-connect + • Processing helm chart raw-init-zarf-registry-registry-connect:0.1.1680014363 from Zarf-generated + helm chart + • Processing helm chart raw-init-zarf-registry-registry-connect:0.1.1680014363 from Zarf-generated + helm chart + • Starting helm chart generation kep-1755-registry-annotation + • Starting helm chart generation kep-1755-registry-annotation + • Processing helm chart raw-init-zarf-registry-kep-1755-registry-annotation:0.1.1680014363 from + Zarf-generated helm chart + • Processing helm chart raw-init-zarf-registry-kep-1755-registry-annotation:0.1.1680014363 from + Zarf-generated helm chart + +
+ + 📦 ZARF-AGENT COMPONENT + + +
+ + • Opening tunnel 62284 -> 5000 for svc/zarf-docker-registry in namespace zarf + • Creating port forwarding tunnel at http://127.0.0.1:62284/v2/_catalog + • Storing images in the zarf registry + • Storing images in the zarf registry + • Starting helm chart generation zarf-agent + • Starting helm chart generation zarf-agent + • Processing helm chart raw-init-zarf-agent-zarf-agent:0.1.1680014363 from Zarf-generated helm chart + • Processing helm chart raw-init-zarf-agent-zarf-agent:0.1.1680014363 from Zarf-generated helm chart + Zarf deployment complete + + + Application | Username | Password | Connect + Registry | zarf-push | DdarrzTahz6oclGTUAUOfbsY | zarf connect registry + + +
+ + \ No newline at end of file diff --git a/docs/.images/walkthroughs/zarf_tools_monitor.png b/docs/.images/walkthroughs/zarf_tools_monitor.png new file mode 100644 index 0000000000..ddd2e22aa7 Binary files /dev/null and b/docs/.images/walkthroughs/zarf_tools_monitor.png differ diff --git a/docs/13-walkthroughs/1-initializing-a-k8s-cluster.md b/docs/13-walkthroughs/1-initializing-a-k8s-cluster.md index 09737058d3..ba7d74b190 100644 --- a/docs/13-walkthroughs/1-initializing-a-k8s-cluster.md +++ b/docs/13-walkthroughs/1-initializing-a-k8s-cluster.md @@ -1,42 +1,36 @@ # Initializing a K8s Cluster - -Before you're able to deploy an application package to a cluster, you need to initialize the cluster. This is done by running the [`zarf init`](../4-user-guide/1-the-zarf-cli/100-cli-commands/zarf_init.md) command. The `zarf init` command uses a specialized package that we have been calling an 'init-package'. More information about this specific package can be found [here](../4-user-guide/2-zarf-packages/3-the-zarf-init-package.md). -## Walkthrough Prerequisites +In this walkthrough, we will demonstrate how to initialize Zarf onto a K8s cluster. This is done by running the [`zarf init`](../4-user-guide/1-the-zarf-cli/100-cli-commands/zarf_init.md) command, which uses a specialized package called an 'init-package'. More information about this specific package can be found [here](../4-user-guide/2-zarf-packages/3-the-zarf-init-package.md). -1. The [Zarf](https://github.com/defenseunicorns/zarf) repository cloned: ([`git clone` Instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)) -1. Zarf binary installed on your $PATH: ([Install Instructions](../3-getting-started.md#installing-zarf)) -1. An init-package built/downloaded: ([init-package Build Instructions](./0-using-zarf-package-create.md)) or ([Download Location](https://github.com/defenseunicorns/zarf/releases)) -1. A Kubernetes cluster to work with: ([Local k8s Cluster Instructions](./#setting-up-a-local-kubernetes-cluster)) +## Prerequisites -## Running the init Command - -Initializing a cluster is done with a single command, `zarf init`. +- The [Zarf](https://github.com/defenseunicorns/zarf) repository cloned: ([`git clone` Instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)) +- Zarf binary installed on your $PATH: ([Install Instructions](../3-getting-started.md#installing-zarf)) +- An init-package built/downloaded: ([init-package Build Instructions](./0-using-zarf-package-create.md)) or ([Download Location](https://github.com/defenseunicorns/zarf/releases)) +- A Kubernetes cluster to work with: ([Local k8s Cluster Instructions](./#setting-up-a-local-kubernetes-cluster)) -```bash -# Ensure you are in the directory where the init-package.tar.zst is located +## Walkthrough -zarf init # Run the initialization command - # Type `y` when asked if we're sure that we want to deploy the package and hit enter - # Type `n` when asked if we want to deploy the 'k3s component' and hit enter - # Type `n` when asked if we want to deploy the 'logging component' and hit enter (optional) - # Type `n` when asked if we want to deploy the 'git-server component' and hit enter (optional) -``` +1. Run the `zarf init` command on your cluster. -### Confirming the Deployment +```sh +$ zarf init +``` -Just like how we got a prompt when creating a package in the prior walkthrough, we will also get a prompt when deploying a package. -![Confirm Package Deploy](../.images/walkthroughs/package_deploy_confirm.png) -Since there are container images within our init-package, we also get a notification about the [Software Bill of Materials (SBOM)](https://www.ntia.gov/SBOM) Zarf included for our package with the file location of where the [SBOM Dashboard](../7-dashboard-ui/1-sbom-dashboard.md) can be viewed. +2. When prompted to deploy the package select `y` for Yes, then hit the `enter` key.
-### Declining The Optional Components +3. Decline Optional Components -The init package comes with a few optional components that can be installed. For now we will ignore the optional components but more information about the init-package and its components can be found [here](../4-user-guide/2-zarf-packages/3-the-zarf-init-package.md). +:::info +More information about the init-package and its components can be found [here](../4-user-guide/2-zarf-packages/3-the-zarf-init-package.md) +::: + -![Optional init Components](../.images/walkthroughs/optional_init_comonents.png) +:::note +You will only be prompted to deploy the k3s component if you are on a Linux machine +::: ### Validating the Deployment - After the `zarf init` command is done running, you should see a few new `zarf` pods in the Kubernetes cluster. ```bash @@ -44,11 +38,12 @@ zarf tools monitor # Note you can press `0` if you want to see all namespaces and CTRL-C to exit ``` +![Zarf Tools Monitor](../.images/walkthroughs/zarf_tools_monitor.png) ## Cleaning Up -The [`zarf destroy`](../4-user-guide/1-the-zarf-cli/100-cli-commands/zarf_destroy.md) command will remove all of the resources that were created by the initialization command. Since this walkthrough involved a kubernetes cluster that was already existing, this command will leave you with a clean cluster that you can either destroy or use for another walkthrough. +The [`zarf destroy`](../4-user-guide/1-the-zarf-cli/100-cli-commands/zarf_destroy.md) command will remove all of the resources that were created by the initialization command. This command will leave you with a clean cluster that you can either destroy or use for another walkthrough. -```bash +```sh zarf destroy --confirm -``` +``` \ No newline at end of file diff --git a/docs/13-walkthroughs/4-creating-a-k8s-cluster-with-zarf.md b/docs/13-walkthroughs/4-creating-a-k8s-cluster-with-zarf.md index a36ec60355..77556e8806 100644 --- a/docs/13-walkthroughs/4-creating-a-k8s-cluster-with-zarf.md +++ b/docs/13-walkthroughs/4-creating-a-k8s-cluster-with-zarf.md @@ -1,18 +1,66 @@ -# Initializing a New K8s Cluster +# Creating a K8s Cluster with Zarf -:::caution Hard Hat Area -This page is still being developed. More content will be added soon! +In this walkthrough, we will demonstrate how to use Zarf on a fresh Linux machine to deploy a [k3s](https://k3s.io/) cluster through Zarf's `k3s` component. + +## System Requirements +- `root` access on a Linux machine + +:::info REQUIRES ROOT +The 'k3s' component requires root access (not just `sudo`!) when deploying as it will modify your host machine to install the cluster. +::: + +## Prerequisites +- The [Zarf](https://github.com/defenseunicorns/zarf) repository cloned: ([`git clone` Instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)) +- Zarf binary installed on your $PATH: ([Install Instructions](../3-getting-started.md#installing-zarf)) +- An init-package built/downloaded: ([init-package Build Instructions](./0-using-zarf-package-create.md)) or ([Download Location](https://github.com/defenseunicorns/zarf/releases)) + +## Walkthrough + +1. Run the `zarf init` command as `root`. + +```sh +# zarf init +``` + +2. Confirm Package Deployment:
+- When prompted to deploy the package select `y` for Yes, then hit the `enter` key.
+ +3. Confirm k3s Component Deployment:
+- When prompted to deploy the k3s component select `y` for Yes, then hit the `enter` key. + + + +:::tip +You can automatically accept the k3s component and confirm the package using the `--components` and `--confirm` flags. + +```sh +$ zarf init --components="k3s" --confirm +``` +::: + +### Validating the Deployment +After the `zarf init` command is done running, you should see a k3s cluster running and a few `zarf` pods in the Kubernetes cluster. + +```sh +# zarf tools monitor +``` +:::note +You can press `0` if you want to see all namespaces and CTRL-C to exit ::: -In this walkthrough, we are going to show how you can use Zarf on a fresh linux machine to deploy a [k3s](https://k3s.io/) cluster through Zarf's `k3s` component +### Accessing the Cluster as a Normal User +By default, the k3s component will only automatically provide cluster access to the root user. To access the cluster as another user, you can run the following to setup the `~/.kube/config` file: +```sh +# cp /root/.kube/config /home/otheruser/.kube +# chown otheruser /home/otheruser/.kube/config +# chgrp otheruser /home/otheruser/.kube/config +``` -## Walkthrough Prerequisites -1. The [Zarf](https://github.com/defenseunicorns/zarf) repository cloned: ([`git clone` Instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)) -1. Zarf binary installed on your $PATH: ([Install Instructions](../3-getting-started.md#installing-zarf)) -1. An init-package built/downloaded: ([init-package Build Instructions](./0-using-zarf-package-create.md)) or ([Download Location](https://github.com/defenseunicorns/zarf/releases)) -1. `root` access on a Linux machine +## Cleaning Up -## Install the k3s component +The [`zarf destroy`](../4-user-guide/1-the-zarf-cli/100-cli-commands/zarf_destroy.md) command will remove all of the resources, including the k3s cluster, that was created by the initialization command. -To install the k3s component, follow the [Initializing a Cluster Instructions](./1-initializing-a-k8s-cluster.md) as `root`, and instead answer `y` when asked to install the `k3s` component +```sh +zarf destroy --confirm +``` \ No newline at end of file