-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add an app to Kubernetes apps section
- Loading branch information
1 parent
5207b01
commit bdc3153
Showing
12 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
docs/kubernetes/apps/statefulset/service-nginx-headless.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,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginxs # Plural because it sets up DNS for each replica in the StatefulSet (e.g. nginx-0.nginxs.default.svc.cluster.local) | ||
spec: | ||
type: ClusterIP | ||
clusterIP: None # This makes it a "headless" service | ||
selector: | ||
app: nginx | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 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,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx # singular since it points to a single cluster IP | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: nginx | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 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,45 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: nginx-with-init-containers | ||
spec: | ||
serviceName: nginxs # Headless service | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: nginx-app | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx-app | ||
spec: | ||
initContainers: | ||
- name: populate-default-html | ||
image: nginx:1.26.0 | ||
command: | ||
- bash | ||
- "-c" | ||
- | | ||
set -ex | ||
[[ $HOSTNAME =~ -([0-9]+)$ ]] || exit 1 | ||
ordinal=${BASH_REMATCH[1]} | ||
echo "<h1>Hello from pod $ordinal</h1>" > /usr/share/nginx/html/index.html | ||
volumeMounts: | ||
- name: data | ||
mountPath: /usr/share/nginx/html | ||
containers: | ||
- name: nginx | ||
image: nginx:1.26.0 | ||
volumeMounts: | ||
- name: data | ||
mountPath: /usr/share/nginx/html | ||
|
||
volumeClaimTemplates: # PersistentVolumeClaim templates for each replica | ||
- metadata: | ||
name: data | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
storageClassName: "standard" | ||
resources: | ||
requests: | ||
storage: 100Mi |