diff --git a/README.md b/README.md index 96635b5..0cff769 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,6 @@ This repository contains examples of how to use Fleet using different approaches | [simple](simple/) | The minimally viable repo to deploy raw Kubernetes resources | | [manifest](manifest/) | A full example of using raw Kubernetes YAML and customizing it per target cluster | | [helm](helm/) | A full example of using Helm and customizing it per target cluster | -| [kustomize](kustomize/) | A full example of using Kustomize and customizing it per target cluster | \ No newline at end of file +| [helm-external](helm-external/) | A full example of using a Helm chart that is downloaded from a third party source and customizing it per target cluster | +| [kustomize](kustomize/) | A full example of using Kustomize and customizing it per target cluster | +| [helm-kustomize](helm-kustomize/) | A full example of using Kustomize to modify a third party Helm chart | diff --git a/helm-external/README.md b/helm-external/README.md new file mode 100644 index 0000000..180602e --- /dev/null +++ b/helm-external/README.md @@ -0,0 +1,22 @@ +# Helm External Example + +This example will deploy the [Kubernetes sample guestbook](https://github.com/kubernetes/examples/tree/master/guestbook/) application as +packaged as a Helm chart downloaded from a third party source. +The app will be deployed into the `fleet-helm-external-example` namespace. + +The application will be customized as follows per environment: + +* Dev clusters: Only the redis leader is deployed and not the followers. +* Test clusters: Scale the front deployment to 3 +* Prod clusters: Scale the front deployment to 3 and set the service type to LoadBalancer + +```yaml +kind: GitRepo +apiVersion: fleet.cattle.io/v1alpha1 +metadata: + name: helm-external + namespace: fleet-local +spec: + repo: https://github.com/rancher/fleet-examples/ + bundleDirs: helm-external +``` \ No newline at end of file diff --git a/helm-external/fleet.yaml b/helm-external/fleet.yaml new file mode 100644 index 0000000..ec37c1c --- /dev/null +++ b/helm-external/fleet.yaml @@ -0,0 +1,24 @@ +namespace: fleet-helm-external-example +chart: https://github.com/rancher/fleet-examples/releases/download/example/guestbook-0.0.0.tgz +targets: +- name: dev + values: + replication: false + clusterSelector: + matchLabels: + env: dev + +- name: test + values: + replicas: 3 + clusterSelector: + matchLabels: + env: test + +- name: prod + values: + serviceType: LoadBalancer + replicas: 3 + clusterSelector: + matchLabels: + env: prod diff --git a/helm-kustomize/README.md b/helm-kustomize/README.md new file mode 100644 index 0000000..195e207 --- /dev/null +++ b/helm-kustomize/README.md @@ -0,0 +1,22 @@ +# Helm Kustomize Example + +This example will deploy the [Kubernetes sample guestbook](https://github.com/kubernetes/examples/tree/master/guestbook/) application as +packaged as a Helm chart downloaded from a third party source and will modify the helm chart using Kustomize. +The app will be deployed into the `fleet-helm-kustomize-example` namespace. + +The application will be customized as follows per environment: + +* Dev clusters: Only the redis leader is deployed and not the followers. +* Test clusters: Scale the front deployment to 3 +* Prod clusters: Scale the front deployment to 3 and set the service type to LoadBalancer + +```yaml +kind: GitRepo +apiVersion: fleet.cattle.io/v1alpha1 +metadata: + name: helm-kustomize + namespace: fleet-local +spec: + repo: https://github.com/rancher/fleet-examples/ + bundleDirs: helm-kustomize +``` \ No newline at end of file diff --git a/helm-kustomize/fleet.yaml b/helm-kustomize/fleet.yaml new file mode 100644 index 0000000..e582873 --- /dev/null +++ b/helm-kustomize/fleet.yaml @@ -0,0 +1,23 @@ +namespace: fleet-helm-kustomize-example +chart: https://github.com/rancher/fleet-examples/releases/download/example/guestbook-0.0.0.tgz +targets: +- name: dev + clusterSelector: + matchLabels: + env: dev + # NOTE: This directory is always relative to ./kustomize + kustomizeDir: overlays/dev + +- name: test + clusterSelector: + matchLabels: + env: test + # NOTE: This directory is always relative to ./kustomize + kustomizeDir: overlays/test + +- name: prod + clusterSelector: + matchLabels: + env: prod + # NOTE: This directory is always relative to ./kustomize + kustomizeDir: overlays/prod diff --git a/helm-kustomize/kustomize/overlays/dev/kustomization.yaml b/helm-kustomize/kustomize/overlays/dev/kustomization.yaml new file mode 100644 index 0000000..c3759a0 --- /dev/null +++ b/helm-kustomize/kustomize/overlays/dev/kustomization.yaml @@ -0,0 +1,3 @@ +patches: +- redis-slave-deployment.yaml +- redis-slave-service.yaml diff --git a/helm-kustomize/kustomize/overlays/dev/redis-slave-deployment.yaml b/helm-kustomize/kustomize/overlays/dev/redis-slave-deployment.yaml new file mode 100644 index 0000000..238ee8c --- /dev/null +++ b/helm-kustomize/kustomize/overlays/dev/redis-slave-deployment.yaml @@ -0,0 +1,6 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: redis-slave +spec: + replicas: 0 diff --git a/helm-kustomize/kustomize/overlays/dev/redis-slave-service.yaml b/helm-kustomize/kustomize/overlays/dev/redis-slave-service.yaml new file mode 100644 index 0000000..d2a93da --- /dev/null +++ b/helm-kustomize/kustomize/overlays/dev/redis-slave-service.yaml @@ -0,0 +1,7 @@ +kind: Service +apiVersion: v1 +metadata: + name: redis-slave +spec: + selector: + role: master diff --git a/helm-kustomize/kustomize/overlays/prod/frontend-deployment.yaml b/helm-kustomize/kustomize/overlays/prod/frontend-deployment.yaml new file mode 100644 index 0000000..f62f81c --- /dev/null +++ b/helm-kustomize/kustomize/overlays/prod/frontend-deployment.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frontend +spec: + replicas: 3 diff --git a/helm-kustomize/kustomize/overlays/prod/frontend-service.yaml b/helm-kustomize/kustomize/overlays/prod/frontend-service.yaml new file mode 100644 index 0000000..a93ecd6 --- /dev/null +++ b/helm-kustomize/kustomize/overlays/prod/frontend-service.yaml @@ -0,0 +1,6 @@ +kind: Service +apiVersion: v1 +metadata: + name: frontend +spec: + type: LoadBalancer diff --git a/helm-kustomize/kustomize/overlays/prod/kustomization.yaml b/helm-kustomize/kustomize/overlays/prod/kustomization.yaml new file mode 100644 index 0000000..3529762 --- /dev/null +++ b/helm-kustomize/kustomize/overlays/prod/kustomization.yaml @@ -0,0 +1,3 @@ +patches: +- frontend-deployment.yaml +- frontend-service.yaml diff --git a/helm-kustomize/kustomize/overlays/test/frontend-deployment.yaml b/helm-kustomize/kustomize/overlays/test/frontend-deployment.yaml new file mode 100644 index 0000000..f62f81c --- /dev/null +++ b/helm-kustomize/kustomize/overlays/test/frontend-deployment.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frontend +spec: + replicas: 3 diff --git a/helm-kustomize/kustomize/overlays/test/kustomization.yaml b/helm-kustomize/kustomize/overlays/test/kustomization.yaml new file mode 100644 index 0000000..cae2c12 --- /dev/null +++ b/helm-kustomize/kustomize/overlays/test/kustomization.yaml @@ -0,0 +1,2 @@ +patches: +- frontend-deployment.yaml diff --git a/helm/README.md b/helm/README.md index 8912576..37830d8 100644 --- a/helm/README.md +++ b/helm/README.md @@ -8,4 +8,15 @@ The application will be customized as follows per environment: * Dev clusters: Only the redis leader is deployed and not the followers. * Test clusters: Scale the front deployment to 3 -* Prod clusters: Scale the front deployment to 3 and set the service type to LoadBalancer \ No newline at end of file +* Prod clusters: Scale the front deployment to 3 and set the service type to LoadBalancer + +```yaml +kind: GitRepo +apiVersion: fleet.cattle.io/v1alpha1 +metadata: + name: helm + namespace: fleet-local +spec: + repo: https://github.com/rancher/fleet-examples/ + bundleDirs: helm +``` \ No newline at end of file diff --git a/kustomize/README.md b/kustomize/README.md index 8d53c19..8717a01 100644 --- a/kustomize/README.md +++ b/kustomize/README.md @@ -7,4 +7,15 @@ The application will be customized as follows per environment: * Dev clusters: Only the redis leader is deployed and not the followers. * Test clusters: Scale the front deployment to 3 -* Prod clusters: Scale the front deployment to 3 and set the service type to LoadBalancer \ No newline at end of file +* Prod clusters: Scale the front deployment to 3 and set the service type to LoadBalancer + +```yaml +kind: GitRepo +apiVersion: fleet.cattle.io/v1alpha1 +metadata: + name: kustomize + namespace: fleet-local +spec: + repo: https://github.com/rancher/fleet-examples/ + bundleDirs: kustomize +``` \ No newline at end of file diff --git a/manifests/README.md b/manifests/README.md index 7394d46..4185b36 100644 --- a/manifests/README.md +++ b/manifests/README.md @@ -7,4 +7,15 @@ The application will be customized as follows per environment: * Dev clusters: Only the redis leader is deployed and not the followers. * Test clusters: Scale the front deployment to 3 -* Prod clusters: Scale the front deployment to 3 and set the service type to LoadBalancer \ No newline at end of file +* Prod clusters: Scale the front deployment to 3 and set the service type to LoadBalancer + +```yaml +kind: GitRepo +apiVersion: fleet.cattle.io/v1alpha1 +metadata: + name: manifests + namespace: fleet-local +spec: + repo: https://github.com/rancher/fleet-examples/ + bundleDirs: manifests +``` \ No newline at end of file diff --git a/simple/README.md b/simple/README.md index 6809d46..e3af027 100644 --- a/simple/README.md +++ b/simple/README.md @@ -1,4 +1,15 @@ # Simple Example This example will deploy the [Kubernetes sample guestbook](https://github.com/kubernetes/examples/tree/master/guestbook/) application. -The app will be deployed into the `default` namespace. \ No newline at end of file +The app will be deployed into the `default` namespace. + +```yaml +kind: GitRepo +apiVersion: fleet.cattle.io/v1alpha1 +metadata: + name: simple + namespace: fleet-local +spec: + repo: https://github.com/rancher/fleet-examples/ + bundleDirs: simple +``` \ No newline at end of file