### Start Interactive Bootstrap Wizard Source: https://docs.gitops.weaveworks.org/docs/enterprise/getting-started/install-enterprise-cli Run this command to launch the step-by-step interactive installation wizard. ```bash gitops bootstrap ``` -------------------------------- ### gitops CLI examples: help and version Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops Shows example commands for the gitops CLI: getting help for a subcommand and displaying version information. The output includes a link to the documentation. ```bash # Get help for gitops create dashboard command gitops create dashboard -h gitops help create dashboard # Get the version of gitops along with commit, branch, and flux version gitops version To learn more, you can find our documentation at https://docs.gitops.weaveworks.org/ ``` -------------------------------- ### Get CLI configuration and generate hashed secret Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_get Examples showing how to retrieve the CLI configuration and generate a bcrypt hash for a password. ```bash # Get the CLI configuration for Weave GitOps gitops get config # Generate a hashed secret PASSWORD="" echo -n $PASSWORD | gitops get bcrypt-hash ``` -------------------------------- ### Load completions for every new fish session Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_completion_fish Use this command to install fish completions for all new sessions. Execute once and then start a new shell for the setup to take effect. ```bash gitops completion fish > ~/.config/fish/completions/gitops.fish ``` -------------------------------- ### Install Quickstart Templates HelmRelease Source: https://docs.gitops.weaveworks.org/docs/gitops-templates/quickstart-templates Add this HelmRelease object to your Weave GitOps Enterprise configuration repo to deploy the quickstart templates. After committing and merging, the templates chart will be deployed and available in the UI Templates tab. ```yaml --- apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: GitRepository metadata: name: weave-gitops-quickstart namespace: flux-system spec: interval: 10m0s ref: branch: main url: https://github.com/weaveworks/weave-gitops-quickstart --- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: quickstart-templates namespace: flux-system spec: chart: spec: chart: "quickstart-templates" version: ">=0.1.0" sourceRef: kind: GitRepository name: weave-gitops-quickstart namespace: flux-system interval: 10m0s ``` -------------------------------- ### Example: print CLI configuration Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_get_config Example command that prints out the CLI configuration for Weave GitOps. ```bash # Prints out the CLI configuration for Weave GitOps gitops get config ``` -------------------------------- ### gitops create terraform examples Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_create_terraform Examples showing how to create a Terraform resource in the default namespace and how to export the manifest to standard output. ```bash # Create a Terraform resource in the default namespace gitops create terraform -n default my-resource --source GitRepository/my-project --path ./terraform --interval 15m # Create and export a Terraform resource manifest to the standard output gitops create terraform -n default my-resource --source GitRepository/my-project --path ./terraform --interval 15m --export ``` -------------------------------- ### Install Weave GitOps Enterprise CLI with curl Source: https://docs.gitops.weaveworks.org/docs/enterprise/getting-started/install-enterprise-azure Downloads and installs the gitops binary using curl, moves it to /usr/local/bin, and verifies the installation with gitops version. ```bash curl --silent --location "https://artifacts.wge.dev.weave.works/releases/bin/0.27.0/gitops-$(uname)-$(uname -m).tar.gz" | tar xz -C /tmp sudo mv /tmp/gitops /usr/local/bin gitops version ``` -------------------------------- ### Get command help options Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_get Displays the help options available for the get command. ```bash -h, --help help for get ``` -------------------------------- ### Example: Get runner logs of a Terraform object Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_logs_terraform Example command to get the runner logs of a Terraform object in the 'flux-system' namespace. ```bash # Get the runner logs of a Terraform object in the "flux-system" namespace gitops logs terraform --namespace flux-system my-resource ``` -------------------------------- ### Install GitOps CLI via Homebrew Source: https://docs.gitops.weaveworks.org/docs/open-source/getting-started/install-OSS Use Homebrew to tap the Weaveworks repository and install the GitOps CLI. ```bash brew tap weaveworks/tap brew install weaveworks/tap/gitops ``` -------------------------------- ### Install GitOps CLI via curl Source: https://docs.gitops.weaveworks.org/docs/open-source/getting-started/install-OSS Download and install the Weave GitOps CLI using curl. ```bash curl --silent --location "https://github.com/weaveworks/weave-gitops/releases/download/v0.38.0/gitops-$(uname)-$(uname -m).tar.gz" | tar xz -C /tmp sudo mv /tmp/gitops /usr/local/bin gitops version ``` -------------------------------- ### Example `make` output for image sync Source: https://docs.gitops.weaveworks.org/docs/enterprise/getting-started/install-enterprise-airgap Example output from running `make` in the resources directory. It shows the command that pulls and pushes the flintlock-kernel image to a private registry, including the digest and status messages. ```shell ➜ resources git:(docs-airgap-install) ✗ make kubectl get microvmmachinetemplates --all-namespaces -o jsonpath="{.items[*].spec.template.spec.kernel.image}"|tr -s '[[:space:]]' '\n' \ | sort | uniq | xargs -L 1 -I {} ./image-pull-push.sh {} docker-registry:5000 5.10.77: Pulling from weaveworks-liquidmetal/flintlock-kernel Digest: sha256:5ef5f3f5b42a75fdb69cdd8d65f5929430f086621e61f00694f53fe351b5d466 Status: Image is up to date for ghcr.io/weaveworks-liquidmetal/flintlock-kernel:5.10.77 ghcr.io/weaveworks-liquidmetal/flintlock-kernel:5.10.77 ...5.10.77: digest: sha256:5ef5f3f5b42a75fdb69cdd8d65f5929430f086621e61f00694f53fe351b5d466 size: 739 ``` -------------------------------- ### Kustomization Configuration for Policies Source: https://docs.gitops.weaveworks.org/docs/policy/commit-time-checks Example kustomization.yaml file defining the resources for the policy directory. ```yaml # kustomization.yaml kind: Kustomization apiVersion: kustomize.config.k8s.io/v1beta1 resources: - minimum-replica-count.yaml - privilege-escalation.yaml - privileged-mode.yaml ``` -------------------------------- ### Install TF-controller with Helm Source: https://docs.gitops.weaveworks.org/docs/terraform/get-started-terraform Installs TF-controller using Helm. Adds the tf-controller Helm repository and installs the chart into the flux-system namespace. Requires Flux to be installed first. ```shell # Add tf-controller helm repository helm repo add tf-controller https://weaveworks.github.io/tf-controller/ # Install tf-controller helm upgrade -i tf-controller tf-controller/tf-controller \ --namespace flux-system ``` -------------------------------- ### Linkerd installation manifests (namespace, source, HelmRelease) Source: https://docs.gitops.weaveworks.org/docs/progressive-delivery/progressive-delivery-flagger-install These three manifests define the Linkerd installation: a Namespace, a HelmRepository for the Linkerd Helm repo, and a HelmRelease that installs Linkerd and Linkerd-Viz. The HelmRelease references the generated certificates via valuesFrom and sets the issuer certificate expiry. The crtExpiry value must match the certificate creation date. ```yaml --- apiVersion: v1 kind: Namespace metadata: name: linkerd labels: config.linkerd.io/admission-webhooks: disabled ``` ```yaml --- apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: HelmRepository metadata: name: linkerd spec: interval: 1h url: https://helm.linkerd.io/stable ``` ```yaml --- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: linkerd spec: interval: 10m chart: spec: chart: linkerd2 reconcileStrategy: ChartVersion sourceRef: kind: HelmRepository name: linkerd install: crds: Create upgrade: crds: CreateReplace valuesFrom: - kind: Secret name: linkerd-certs valuesKey: ca.crt targetPath: identityTrustAnchorsPEM - kind: Secret name: linkerd-certs valuesKey: issuer.crt targetPath: identity.issuer.tls.crtPEM - kind: Secret name: linkerd-certs valuesKey: issuer.key targetPath: identity.issuer.tls.keyPEM values: installNamespace: false identity: issuer: crtExpiry: "2023-07-18T20:00:00Z" # Change this to match generated certificate expiry date --- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: linkerd-viz spec: interval: 10m dependsOn: - name: linkerd chart: spec: chart: linkerd-viz reconcileStrategy: ChartVersion sourceRef: kind: HelmRepository name: linkerd ``` -------------------------------- ### Example: generate bcrypt hash from password Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_get_bcrypt-hash Example of using the command with a password stored in an environment variable. The password is echoed without a newline and piped to the command. ```bash PASSWORD="" echo -n $PASSWORD | gitops get bcrypt-hash ``` -------------------------------- ### Replan Terraform object example Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_replan_terraform Example command to replan the Terraform plan of a Terraform object from the 'flux-system' namespace. ```bash # Replan the Terraform plan of a Terraform object from the "flux-system" namespace gitops replan terraform --namespace flux-system my-resource ``` -------------------------------- ### Install gitops-ee CLI via Homebrew Source: https://docs.gitops.weaveworks.org/docs/enterprise/getting-started/install-enterprise-cli Use this command to install the latest version of the Weave GitOps Enterprise CLI. ```bash brew install weaveworks/tap/gitops-ee ``` -------------------------------- ### Export GPG key fingerprint Source: https://docs.gitops.weaveworks.org/docs/secrets/setup-sops Lists secret keys to get the fingerprint and exports it as KEY_FP. The output shows an example fingerprint. ```bash gpg --list-secret-keys "${KEY_NAME}" sec rsa4096 2020-09-06 [SC] 710DC0DB6C1662F707095FC30233CB21E656A3CB export KEY_FP="710DC0DB6C1662F707095FC30233CB21E656A3CB" ``` -------------------------------- ### Policy Profile values file example Source: https://docs.gitops.weaveworks.org/docs/policy/weave-policy-profile Example of the profile values file showing configuration for policy-agent and policySource. Includes settings for failurePolicy, cert-manager usage, persistence, audit and admission features, and policy source options. ```yaml policy-agent: failurePolicy: Ignore # If you don't want to use cert-manager, set useCertManager to false and provide your own certs useCertManager: true certificate: "" key: "" caCertificate: "" persistence: enabled: false # claimStorage: 1Gi # sinkDir: /tmp # storageClassName: standard config: accountId: "" clusterId: "" audit: # Enable audit functionality enabled: false # sinks: # # Enable writing violations as K8s events # k8sEventsSink: # enabled: true admission: # Enable admission functionality enabled: true # mutate: true # enable mutating violating resources sinks: # Enable writing violations as K8s events k8sEventsSink: enabled: true policySource: enabled: false # url: ssh://git@github.com/weaveworks/policy-library # tag: v1.0.0 # branch: # path: ./ # Could be a path to the policies dir or a kustomization.yaml file # secretRef: policy-library-auth # (Optional): Name of the K8s secret with private repo auth credentials # sourceRef: # Could specify a name for an existing GitSource reference instead of creating a new one # kind: GitRepository # name: policy-library # namespace: flux-system ``` -------------------------------- ### Options for gitops get bcrypt-hash Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_get_bcrypt-hash Lists the command-specific options, including the help flag. ```bash -h, --help help for bcrypt-hash ``` -------------------------------- ### Verify Get Access Allowed for Pipeline Controller Source: https://docs.gitops.weaveworks.org/docs/pipelines/promoting-applications Verify that the Pipeline Controller can get the specific app-promotion-credentials secret. The command succeeds and shows the secret details, confirming get access is allowed. ```bash $ kubectl get secret -n podinfo --as=system:serviceaccount:flux-system:chart-pipeline-controller app-promotion-credentials NAME TYPE DATA AGE app-promotion-credentials Opaque 1 21m ``` -------------------------------- ### Policy Kustomize Directory Structure Source: https://docs.gitops.weaveworks.org/docs/policy/commit-time-checks Example directory tree for a policies kustomize directory. ```text └── policies ├── kustomization.yaml ├── minimum-replica-count.yaml ├── privileged-mode.yaml └── privilege-escalation.yaml ``` -------------------------------- ### gitops get config command syntax Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_get_config Shows the basic syntax for the `gitops get config` command. ```bash gitops get config [flags] ``` -------------------------------- ### Parent command options Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_get Lists the inherited options for the get command, including authentication and connection settings. ```bash -e, --endpoint WEAVE_GITOPS_ENTERPRISE_API_URL The Weave GitOps Enterprise HTTP API endpoint can be set with WEAVE_GITOPS_ENTERPRISE_API_URL environment variable --insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure --kubeconfig string Paths to a kubeconfig. Only required if out-of-cluster. -n, --namespace string The namespace scope for this operation (default "flux-system") -p, --password WEAVE_GITOPS_PASSWORD The Weave GitOps Enterprise password for authentication can be set with WEAVE_GITOPS_PASSWORD environment variable -u, --username WEAVE_GITOPS_USERNAME The Weave GitOps Enterprise username for authentication can be set with WEAVE_GITOPS_USERNAME environment variable ``` -------------------------------- ### Configure GitOpsSet with serviceAccountName Source: https://docs.gitops.weaveworks.org/docs/gitopssets/templating-from-generators This example demonstrates how to specify a serviceAccountName in a GitOpsSet, which the controller will impersonate when creating resources. ```yaml apiVersion: templates.weave.works/v1alpha1 kind: GitOpsSet metadata: name: matrix-sample spec: # the controller will impersonate this service account serviceAccountName: test-sa generators: - list: elements: - env: dev team: dev-team - env: production team: ops-team - env: staging team: ops-team templates: - content: kind: Kustomization apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 metadata: name: "{{ .Element.env }}-demo" labels: app.kubernetes.io/name: go-demo app.kubernetes.io/instance: "{{ .Element.env }}" com.example/team: "{{ .Element.team }}" spec: interval: 5m path: "./examples/kustomize/environments/{{ .Element.env }}" prune: true sourceRef: kind: GitRepository name: go-demo-repo ``` -------------------------------- ### Install Weave GitOps with default service account Source: https://docs.gitops.weaveworks.org/docs/open-source/getting-started/aws-marketplace Installs Weave GitOps using the default service account name. The values.yaml file must be created with the admin user credentials, and the Chart URL or file path must be provided. ```yaml gitops: adminUser: create: true username: passwordHash: ``` ```bash helm install wego \ --namespace=flux-system \ --create-namespace \ --set serviceAccountRole="$SA_ARN" \ --values ./values.yaml ``` -------------------------------- ### Define Flagger Namespace, HelmRepository, and HelmRelease manifests Source: https://docs.gitops.weaveworks.org/docs/progressive-delivery/progressive-delivery-flagger-install Create these three files within a directory reconciled by Flux to define the installation environment and components. ```yaml --- apiVersion: v1 kind: Namespace metadata: name: flagger ``` ```yaml --- apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: HelmRepository metadata: name: flagger spec: interval: 1h url: https://flagger.app ``` ```yaml --- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: flagger spec: releaseName: flagger install: crds: Create upgrade: crds: CreateReplace interval: 10m chart: spec: chart: flagger reconcileStrategy: ChartVersion sourceRef: kind: HelmRepository name: flagger values: metricsServer: http://prometheus.linkerd-viz:9090 meshProvider: linkerd --- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: loadtester spec: interval: 10m chart: spec: chart: loadtester reconcileStrategy: ChartVersion sourceRef: kind: HelmRepository name: flagger ``` -------------------------------- ### HelmRelease Manifest with Promotion Marker Source: https://docs.gitops.weaveworks.org/docs/pipelines/promoting-applications Example HelmRelease manifest with a deterministic promotion marker in a comment. The marker value contains three colon-separated components: pipeline namespace, pipeline name, and environment name. ```yaml --- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease spec: chart: spec: version: 0.13.7 # {"$promotion": "pipeline-01:my-app:prod"} ``` -------------------------------- ### Check Linkerd and Linkerd-viz pod status Source: https://docs.gitops.weaveworks.org/docs/progressive-delivery/progressive-delivery-flagger-install Commands to verify that all pods in the linkerd and linkerd-viz namespaces have started successfully after Flux reconciliation. ```bash > kubectl get pods -n linkerd NAME READY STATUS RESTARTS AGE linkerd-destination-66d5668b-4mw49 4/4 Running 0 10m linkerd-identity-6b4658c74b-6nc97 2/2 Running 0 10m linkerd-proxy-injector-6b76789cb4-8vqj4 2/2 Running 0 10m > kubectl get pods -n linkerd-viz NAME READY STATUS RESTARTS AGE grafana-db56d7cb4-xlnn4 2/2 Running 0 10m metrics-api-595c7b564-724ps 2/2 Running 0 10m prometheus-5d4dffff55-8fscd 2/2 Running 0 10m tap-6dcb89d487-5ns8n 2/2 Running 0 10m tap-injector-54895654bb-9xn7k 2/2 Running 0 10m web-6b6f65dbc7-wltdg 2/2 Running 0 10m ``` -------------------------------- ### Kubectl Get ConfigMaps Output Source: https://docs.gitops.weaveworks.org/docs/gitopssets/templating-from-generators The resulting ConfigMaps generated by the Matrix example. ```bash $ kubectl get configmaps NAME DATA AGE demo-configmap-dev-cluster 3 3m19s demo-configmap-prod-cluster 3 3m19s ``` -------------------------------- ### Expose promotion webhook via Helm chart ingress Source: https://docs.gitops.weaveworks.org/docs/pipelines/promoting-applications Configure the Weave GitOps Enterprise Helm chart to expose the promotion webhook via an NGINX ingress. Adjust className and annotations if using a different ingress controller. The externally reachable URL of this service is needed later in the guide. ```yaml spec: values: enablePipelines: true pipeline-controller: promotion: ingress: enabled: true className: nginx annotations: cert-manager.io/cluster-issuer: letsencrypt hosts: - host: promotions.example.org paths: - path: /?(.*) pathType: ImplementationSpecific tls: - secretName: promotions-tls hosts: - promotions.example.org ``` -------------------------------- ### gitops version help options Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_version Displays help information for the version command. ```bash -h, --help help for version ``` -------------------------------- ### Create dex Namespace Source: https://docs.gitops.weaveworks.org/docs/enterprise/getting-started/install-enterprise Defines a Kubernetes Namespace named 'dex' for installing Dex, an identity service that uses OpenID Connect. This is the first step in the Dex and GitHub OIDC example. ```yaml --- apiVersion: v1 kind: Namespace metadata: name: dex ``` -------------------------------- ### Validate Weave GitOps and Flux installation with kubectl get pods Source: https://docs.gitops.weaveworks.org/docs/open-source/getting-started/install-OSS Checks that Weave GitOps and Flux are installed by listing pods in the flux-system namespace. The output shows the expected pods, including ww-gitops-weave-gitops. Give the Flux controllers a couple of minutes to pull the latest commit; if nothing happens, the manifests may not have been exported to the repository. ```bash kubectl get pods -n flux-system ``` ```text NAME READY STATUS RESTARTS AGE helm-controller-5bfd65cd5f-gj5sz 1/1 Running 0 10m kustomize-controller-6f44c8d499-s425n 1/1 Running 0 10m notification-controller-844df5f694-2pfcs 1/1 Running 0 10m source-controller-6b6c7bc4bb-ng96p 1/1 Running 0 10m ww-gitops-weave-gitops-86b645c9c6-k9ftg 1/1 Running 0 5m ``` -------------------------------- ### Resource templates with create-request annotation Source: https://docs.gitops.weaveworks.org/docs/gitops-templates/creating-templates Example of resourcetemplates in a GitOpsTemplate. The first resource (ConfigMap) gets the create-request annotation added by default; the second (HelmRepository) explicitly includes the annotation to enable an 'Edit resource' button in the UI. ```yaml spec: resourcetemplates: - apiVersion: v1 kind: ConfigMap metadata: name: my-configmap data: my-key: my-value - apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: HelmRepository metadata: # This annotation will add an `Edit resource` button in the UI for this resource annotations: templates.weave.works/create-request: '' name: nginx namespace: default ``` -------------------------------- ### Define GitRepository source for TF-controller Source: https://docs.gitops.weaveworks.org/docs/terraform/get-started-terraform Defines a Flux Source controller GitRepository named helloworld in the flux-system namespace, pointing to the tf-controller/helloworld repository on the main branch with a 30s interval. This is the first step in the Quick Start example. ```yaml apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: GitRepository metadata: name: helloworld namespace: flux-system spec: interval: 30s url: https://github.com/tf-controller/helloworld ref: branch: main ``` -------------------------------- ### Check OIDC configuration - command syntax and examples Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_check_oidc-config Shows the basic command syntax and several ways to use `gitops check oidc-config`, including reading from a default Secret, specifying different scopes or username claim, and skipping the cluster Secret. Users must configure the OIDC provider to accept the redirect URI http://localhost:9876. ```shell gitops check oidc-config [flags] ``` ```shell # Check the OIDC configuration stored in the flux-system/oidc-auth Secret gitops check oidc-config # Check a different set of scopes gitops check oidc-config --scopes=openid,groups # Check a different username cliam gitops check oidc-config --claim-username=sub # Check configuration without fetching a Secret from the cluster gitops check oidc-config --skip-secret --client-id=CID --client-secret=SEC --issuer-url=https://example.org ``` -------------------------------- ### Install TF-controller with kubectl (stable release) Source: https://docs.gitops.weaveworks.org/docs/terraform/get-started-terraform Installs TF-controller using the latest stable release manifest. Requires Flux to be installed first via `flux install` or `flux bootstrap`. ```shell kubectl apply -f https://raw.githubusercontent.com/weaveworks/tf-controller/main/docs/release.yaml ``` -------------------------------- ### Install gitopssets-controller via HelmRelease Source: https://docs.gitops.weaveworks.org/docs/gitopssets/gitopssets-installation Use this HelmRelease configuration to install the gitopssets-controller. Ensure Flux is installed before applying these resources to your cluster. ```yaml apiVersion: v1 kind: Namespace metadata: name: gitopssets-system --- apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: HelmRepository metadata: name: weaveworks-oci-charts namespace: gitopssets-system spec: interval: 1m type: oci url: oci://ghcr.io/weaveworks/charts --- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: gitopssets-controller namespace: gitopssets-system spec: interval: 10m chart: spec: chart: gitopssets-controller sourceRef: kind: HelmRepository name: weaveworks-oci-charts namespace: gitopssets-system version: 0.15.3 install: crds: CreateReplace upgrade: crds: CreateReplace ``` -------------------------------- ### Install @weaveworksoss/backstage-plugin-flux Source: https://docs.gitops.weaveworks.org/docs/backstage/intro Install the Flux plugin into your Backstage frontend app from the root directory. Requires the Kubernetes plugin to be installed and configured first. ```bash # From your Backstage root directory yarn add --cwd packages/app @weaveworksoss/backstage-plugin-flux ``` -------------------------------- ### Create infrastructure directory Source: https://docs.gitops.weaveworks.org/docs/terraform/get-started-terraform Creates the directory structure for storing infrastructure manifests. ```bash mkdir -p ./cluster/my-cluster/infra/ ``` -------------------------------- ### Install TF-controller with kubectl (release candidate) Source: https://docs.gitops.weaveworks.org/docs/terraform/get-started-terraform Installs the most recent TF-controller release candidate using the rc.yaml manifest. Requires Flux to be installed first. ```shell kubectl apply -f https://raw.githubusercontent.com/weaveworks/tf-controller/main/docs/rc.yaml ``` -------------------------------- ### Set up access to ChartMuseum (port-forward and hosts entry) Source: https://docs.gitops.weaveworks.org/docs/enterprise/getting-started/install-enterprise-airgap Commands to expose the ChartMuseum service via port-forward and add a hostname entry to /etc/hosts for local access. ```bash #expose kubernetes svc kubectl -n flux-system port-forward svc/helm-repo-chartmuseum 8080:8080 & #add hostname sudo -- sh -c "echo 127.0.0.1 helm-repo-chartmuseum >> /etc/hosts" ``` -------------------------------- ### Load completions for every new session on Linux Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_completion_zsh Execute this once to install the completion script for all new zsh sessions on Linux. ```bash gitops completion zsh > "${fpath[1]}/_gitops" ``` -------------------------------- ### Get a specific Terraform template with gitops get template Source: https://docs.gitops.weaveworks.org/docs/terraform/using-terraform-templates Get a specific Terraform template by name. The output shows the template name, provider (empty), description, and error column. ```shell gitops get template terraform sample-wge-tf-controller-template --endpoint https://localhost:8000 --username= --password= NAME PROVIDER DESCRIPTION ERROR sample-wge-tf-controller-template This is a sample WGE template that will be translated into a tf-controller specific template. ``` -------------------------------- ### Export tenant configuration to file Source: https://docs.gitops.weaveworks.org/docs/workspaces/multi-tenancy Command to save the generated tenant configuration to a file for GitOps deployment. ```bash gitops create tenants --from-file tenants.yaml --export > clusters/management/tenants.yaml ``` -------------------------------- ### Create Weave GitOps dashboard and Terraform resources Source: https://docs.gitops.weaveworks.org/docs/references/cli-reference/gitops_create Examples of using the gitops create command to generate YAML manifests for the Weave GitOps dashboard and Terraform objects. ```bash # Create a HelmRepository and HelmRelease to deploy Weave GitOps gitops create dashboard ww-gitops \ --password=$PASSWORD \ --export > ./clusters/my-cluster/weave-gitops-dashboard.yaml # Create a Terraform object gitops create terraform my-resource \ -n my-namespace \ --source GitRepository/my-project \ --path ./terraform \ --interval 1m \ --export > ./clusters/my-cluster/infra/terraform-my-resource.yaml ``` -------------------------------- ### Install TF-controller with kubectl (specific version) Source: https://docs.gitops.weaveworks.org/docs/terraform/get-started-terraform Installs TF-controller via kubectl using a specific version (v0.14.0). Applies the CRDs, RBAC, and deployment manifests from the release. Requires Flux to be installed first. ```shell export TF_CON_VER=v0.14.0 kubectl apply -f https://github.com/weaveworks/tf-controller/releases/download/${TF_CON_VER}/tf-controller.crds.yaml kubectl apply -f https://github.com/weaveworks/tf-controller/releases/download/${TF_CON_VER}/tf-controller.rbac.yaml kubectl apply -f https://github.com/weaveworks/tf-controller/releases/download/${TF_CON_VER}/tf-controller.deployment.yaml ``` -------------------------------- ### Install Flux CLI via Homebrew Source: https://docs.gitops.weaveworks.org/docs/open-source/getting-started/install-OSS Use Homebrew to install the Flux CLI on macOS. ```bash brew install fluxcd/tap/flux ``` -------------------------------- ### Create tenants with CLI arguments Source: https://docs.gitops.weaveworks.org/docs/workspaces/multi-tenancy Creates tenant resources directly via CLI arguments. Requires cluster connection configuration. Output shows namespaces, service accounts, role bindings, and a policy created. ```shell gitops create tenants --name test-tenant --namespace test-ns1 --namespace test-ns2 ``` ```text namespace/test-ns1 created test-ns1/serviceaccount/test-tenant created test-ns1/rolebinding.rbac.authorization.k8s.io/test-tenant-service-account-cluster-admin created namespace/test-ns2 created test-ns2/serviceaccount/test-tenant created test-ns2/rolebinding.rbac.authorization.k8s.io/test-tenant-service-account-cluster-admin created policy.pac.weave.works/weave.policies.tenancy.test-tenant-allowed-application-deploy created ``` -------------------------------- ### Render template with profile values using gitops create template Source: https://docs.gitops.weaveworks.org/docs/gitops-templates/cli Renders a template with a profile, supplying a values.yaml file to the profile using the --profiles parameter. The profile is specified as a comma-separated string with name, namespace, version, and values file. ```bash gitops create template \ --template-file capd-template.yaml \ --output-dir ./out \ --values CLUSTER_NAME=foo \ --profiles "name=cert-manager,namespace=foo,version=>0.1,values=cert-manager-values.yaml" ```