-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 56bca25
Showing
48 changed files
with
684 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Fleet Examples | ||
|
||
This repository contains examples of how to use Fleet using different approaches. | ||
|
||
| Example | Description | | ||
|-------------|-------------| | ||
| [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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Helm Example | ||
|
||
This example will deploy the [Kubernetes sample guestbook](https://github.com/kubernetes/examples/tree/master/guestbook/) application as | ||
packaged as a Helm chart. | ||
The app will be deployed into the `fleet-helm-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v2 | ||
name: guestbook | ||
description: Sample application | ||
version: 0.0.0 | ||
appVersion: 0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: frontend | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: guestbook | ||
tier: frontend | ||
replicas: {{ .Values.replicas }} | ||
template: | ||
metadata: | ||
labels: | ||
app: guestbook | ||
tier: frontend | ||
spec: | ||
containers: | ||
- name: php-redis | ||
image: gcr.io/google-samples/gb-frontend:v4 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
ports: | ||
- containerPort: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: frontend | ||
labels: | ||
app: guestbook | ||
tier: frontend | ||
spec: | ||
type: "{{ .Values.serviceType }}" | ||
ports: | ||
- port: 80 | ||
selector: | ||
app: guestbook | ||
tier: frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: redis-master | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
spec: | ||
containers: | ||
- name: master | ||
image: redis | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
ports: | ||
- containerPort: 6379 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-master | ||
labels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
spec: | ||
ports: | ||
- port: 6379 | ||
targetPort: 6379 | ||
selector: | ||
app: redis | ||
role: master | ||
tier: backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{{ if .Values.replication }} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: redis-slave | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
replicas: 2 | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
spec: | ||
containers: | ||
- name: slave | ||
image: gcr.io/google_samples/gb-redisslave:v1 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
ports: | ||
- containerPort: 6379 | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-slave | ||
labels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
spec: | ||
ports: | ||
- port: 6379 | ||
selector: | ||
app: redis | ||
{{ if .Values.replication }} | ||
role: slave | ||
{{ else }} | ||
role: master | ||
{{ end }} | ||
tier: backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
replication: true | ||
replicas: 1 | ||
serviceType: NodePort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace: fleet-helm-example | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Helm Example | ||
|
||
This example will deploy the [Kubernetes sample guestbook](https://github.com/kubernetes/examples/tree/master/guestbook/) application | ||
using kustomize. The app will be deployed into the `fleet-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace: fleet-kustomize-example | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: frontend | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: guestbook | ||
tier: frontend | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: guestbook | ||
tier: frontend | ||
spec: | ||
containers: | ||
- name: php-redis | ||
image: gcr.io/google-samples/gb-frontend:v4 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
ports: | ||
- containerPort: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: frontend | ||
labels: | ||
app: guestbook | ||
tier: frontend | ||
spec: | ||
type: NodePort | ||
ports: | ||
- port: 80 | ||
selector: | ||
app: guestbook | ||
tier: frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resources: | ||
- frontend-deployment.yaml | ||
- frontend-service.yaml | ||
- redis-master-deployment.yaml | ||
- redis-master-service.yaml | ||
- redis-slave-deployment.yaml | ||
- redis-slave-service.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: redis-master | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
spec: | ||
containers: | ||
- name: master | ||
image: redis | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
ports: | ||
- containerPort: 6379 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-master | ||
labels: | ||
app: redis | ||
role: master | ||
tier: backend | ||
spec: | ||
ports: | ||
- port: 6379 | ||
targetPort: 6379 | ||
selector: | ||
app: redis | ||
role: master | ||
tier: backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: redis-slave | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
replicas: 2 | ||
template: | ||
metadata: | ||
labels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
spec: | ||
containers: | ||
- name: slave | ||
image: gcr.io/google_samples/gb-redisslave:v1 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
ports: | ||
- containerPort: 6379 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-slave | ||
labels: | ||
app: redis | ||
role: slave | ||
tier: backend | ||
spec: | ||
ports: | ||
- port: 6379 | ||
selector: | ||
app: redis | ||
role: slave | ||
tier: backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
resources: | ||
- overlays/dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resources: | ||
- ../../base | ||
patches: | ||
- redis-slave-deployment.yaml | ||
- redis-slave-service.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: redis-slave | ||
spec: | ||
replicas: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: redis-slave | ||
spec: | ||
selector: | ||
role: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: frontend | ||
spec: | ||
replicas: 3 |
Oops, something went wrong.