Skip to content

Commit

Permalink
feat: DaemonSets best practices on Autopilot tutorial (#836)
Browse files Browse the repository at this point in the history
* DaemonSets best practices tutorial

* Add region tags

* Update autopilot/daemonset-best-practices/README.md

Co-authored-by: Olivier Bourgeois <[email protected]>

---------

Co-authored-by: Olivier Bourgeois <[email protected]>
  • Loading branch information
TheRealSpaceShip and bourgeoisor authored Nov 13, 2023
1 parent 15a481c commit bfc73b0
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
5 changes: 5 additions & 0 deletions autopilot/daemonset-best-practices/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# How to Run DaemonSet on GKE Autopilot

[![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https://github.com/GoogleCloudPlatform/kubernetes-engine-samples&cloudshell_workspace=autopilot/daemonset-best-practices)

This example shows how to apply [best practices](https://cloud.google.com/kubernetes-engine/docs/how-to/deploying-workloads-overview#autopilot-ds-best-practices) for DaemonSet on [Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine) in Autopilot mode.
48 changes: 48 additions & 0 deletions autopilot/daemonset-best-practices/daemon-set.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START gke_autopilot_daemonset_best_practices_daemon_set]
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: hello-daemonset
labels:
app: hello
spec:
selector:
matchLabels:
app: hello
tier: daemonset
template:
metadata:
labels:
app: hello
tier: daemonset
spec:
containers:
- name: hello-daemonset
image: us-docker.pkg.dev/google-samples/containers/gke/hello-app:1.0
ports:
- containerPort: 8080
name: http
resources:
limits:
cpu: 2000m
memory: 2Gi
ephemeral-storage: 1Gi
requests:
cpu: 2000m
memory: 2Gi
ephemeral-storage: 1Gi
# [END gke_autopilot_daemonset_best_practices_daemon_set]
49 changes: 49 additions & 0 deletions autopilot/daemonset-best-practices/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START gke_autopilot_daemonset_best_practices_deployment]
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-app
labels:
app: hello
spec:
replicas: 3
selector:
matchLabels:
app: hello
tier: app
template:
metadata:
labels:
app: hello
tier: app
spec:
containers:
- name: hello-app
image: us-docker.pkg.dev/google-samples/containers/gke/hello-app:1.0
ports:
- containerPort: 8080
name: http
resources:
limits:
cpu: 2000m
memory: 4Gi
ephemeral-storage: 1Gi
requests:
cpu: 2000m
memory: 4Gi
ephemeral-storage: 1Gi
# [END gke_autopilot_daemonset_best_practices_deployment]
24 changes: 24 additions & 0 deletions autopilot/daemonset-best-practices/priority-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START gke_autopilot_daemonset_best_practices_priority_class]
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: daemonset-priority
value: 1000
preemptionPolicy: PreemptLowerPriority
globalDefault: false
description: "User DaemonSet priority"
# [END gke_autopilot_daemonset_best_practices_priority_class]

0 comments on commit bfc73b0

Please sign in to comment.