From 9ee6d9e3e05382b3c3223c8293575140fd6e1b31 Mon Sep 17 00:00:00 2001 From: Pavel Selivanov Date: Thu, 26 Jul 2018 15:13:04 +0200 Subject: [PATCH] add practicies --- practice/helm/fileshare/.helmignore | 21 ++++++ practice/helm/fileshare/Chart.yaml | 5 ++ practice/helm/fileshare/templates/NOTES.txt | 19 +++++ .../helm/fileshare/templates/_helpers.tpl | 32 +++++++++ .../helm/fileshare/templates/configmap.yaml | 28 ++++++++ .../helm/fileshare/templates/deployment.yaml | 64 +++++++++++++++++ .../helm/fileshare/templates/ingress.yaml | 24 +++++++ practice/helm/fileshare/templates/pvc.yaml | 17 +++++ .../helm/fileshare/templates/service.yaml | 19 +++++ practice/helm/fileshare/values.yaml | 36 ++++++++++ practice/kube-basics-practice/Dockerfile | 10 +++ .../kube-basics-practice/docker-entrypoint.sh | 70 +++++++++++++++++++ .../kube-basics-practice/kube/configmap.yaml | 23 ++++++ .../kube-basics-practice/kube/deployment.yaml | 60 ++++++++++++++++ .../kube-basics-practice/kube/ingress.yaml | 12 ++++ practice/kube-basics-practice/kube/pvc.yaml | 10 +++ .../kube-basics-practice/kube/service.yaml | 11 +++ practice/kube-basics/configmap.yaml | 14 ++++ .../deployment-with-configmap.yaml | 55 +++++++++++++++ .../kube-basics/deployment-with-stuff.yaml | 48 +++++++++++++ practice/kube-basics/deployment.yaml | 24 +++++++ practice/kube-basics/ingress.yaml | 12 ++++ practice/kube-basics/pod.yaml | 12 ++++ practice/kube-basics/pvc.yaml | 10 +++ practice/kube-basics/replicaset.yaml | 19 +++++ practice/kube-basics/service.yaml | 11 +++ 26 files changed, 666 insertions(+) create mode 100644 practice/helm/fileshare/.helmignore create mode 100644 practice/helm/fileshare/Chart.yaml create mode 100644 practice/helm/fileshare/templates/NOTES.txt create mode 100644 practice/helm/fileshare/templates/_helpers.tpl create mode 100644 practice/helm/fileshare/templates/configmap.yaml create mode 100644 practice/helm/fileshare/templates/deployment.yaml create mode 100644 practice/helm/fileshare/templates/ingress.yaml create mode 100644 practice/helm/fileshare/templates/pvc.yaml create mode 100644 practice/helm/fileshare/templates/service.yaml create mode 100644 practice/helm/fileshare/values.yaml create mode 100644 practice/kube-basics-practice/Dockerfile create mode 100755 practice/kube-basics-practice/docker-entrypoint.sh create mode 100644 practice/kube-basics-practice/kube/configmap.yaml create mode 100644 practice/kube-basics-practice/kube/deployment.yaml create mode 100644 practice/kube-basics-practice/kube/ingress.yaml create mode 100644 practice/kube-basics-practice/kube/pvc.yaml create mode 100644 practice/kube-basics-practice/kube/service.yaml create mode 100644 practice/kube-basics/configmap.yaml create mode 100644 practice/kube-basics/deployment-with-configmap.yaml create mode 100644 practice/kube-basics/deployment-with-stuff.yaml create mode 100644 practice/kube-basics/deployment.yaml create mode 100644 practice/kube-basics/ingress.yaml create mode 100644 practice/kube-basics/pod.yaml create mode 100644 practice/kube-basics/pvc.yaml create mode 100644 practice/kube-basics/replicaset.yaml create mode 100644 practice/kube-basics/service.yaml diff --git a/practice/helm/fileshare/.helmignore b/practice/helm/fileshare/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/practice/helm/fileshare/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/practice/helm/fileshare/Chart.yaml b/practice/helm/fileshare/Chart.yaml new file mode 100644 index 0000000..98c76fa --- /dev/null +++ b/practice/helm/fileshare/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: fileshare +version: 0.1.0 diff --git a/practice/helm/fileshare/templates/NOTES.txt b/practice/helm/fileshare/templates/NOTES.txt new file mode 100644 index 0000000..7f3fb9a --- /dev/null +++ b/practice/helm/fileshare/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fileshare.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "fileshare.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fileshare.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fileshare.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/practice/helm/fileshare/templates/_helpers.tpl b/practice/helm/fileshare/templates/_helpers.tpl new file mode 100644 index 0000000..7a4cc40 --- /dev/null +++ b/practice/helm/fileshare/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "fileshare.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "fileshare.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "fileshare.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/practice/helm/fileshare/templates/configmap.yaml b/practice/helm/fileshare/templates/configmap.yaml new file mode 100644 index 0000000..1593283 --- /dev/null +++ b/practice/helm/fileshare/templates/configmap.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "fileshare.fullname" . }} + labels: + app: {{ template "fileshare.name" . }} + chart: {{ template "fileshare.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + default.conf: | + server { + listen 80 default_server; + server_name _; + + location / { + return 200 '$hostname\n'; + } + + location /files { + alias /data; + autoindex on; + client_body_temp_path /tmp; + dav_methods PUT DELETE MKCOL COPY MOVE; + create_full_put_path on; + dav_access user:rw group:rw all:r; + } + } diff --git a/practice/helm/fileshare/templates/deployment.yaml b/practice/helm/fileshare/templates/deployment.yaml new file mode 100644 index 0000000..f9d221e --- /dev/null +++ b/practice/helm/fileshare/templates/deployment.yaml @@ -0,0 +1,64 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fileshare.fullname" . }} + labels: + app: {{ template "fileshare.name" . }} + chart: {{ template "fileshare.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "fileshare.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "fileshare.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: / + port: http + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: http + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + initialDelaySeconds: 10 + volumeMounts: + - name: config + mountPath: /etc/nginx/conf.d/ + - name: data + mountPath: /data + resources: +{{ toYaml .Values.resources | indent 12 }} + volumes: + - name: config + configMap: + name: {{ template "fileshare.fullname" . }} + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ template "fileshare.fullname" . }} + {{- else }} + emptyDir: {} + {{- end -}} diff --git a/practice/helm/fileshare/templates/ingress.yaml b/practice/helm/fileshare/templates/ingress.yaml new file mode 100644 index 0000000..5372ea2 --- /dev/null +++ b/practice/helm/fileshare/templates/ingress.yaml @@ -0,0 +1,24 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "fileshare.fullname" . -}} +{{- $ingressPath := .Values.ingress.path -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "fileshare.name" . }} + chart: {{ template "fileshare.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- end }} diff --git a/practice/helm/fileshare/templates/pvc.yaml b/practice/helm/fileshare/templates/pvc.yaml new file mode 100644 index 0000000..632df51 --- /dev/null +++ b/practice/helm/fileshare/templates/pvc.yaml @@ -0,0 +1,17 @@ +{{- if and .Values.persistence.enabled -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "fileshare.fullname" . }} + labels: + app: {{ template "fileshare.name" . }} + chart: {{ template "fileshare.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- end -}} diff --git a/practice/helm/fileshare/templates/service.yaml b/practice/helm/fileshare/templates/service.yaml new file mode 100644 index 0000000..216e0c0 --- /dev/null +++ b/practice/helm/fileshare/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fileshare.fullname" . }} + labels: + app: {{ template "fileshare.name" . }} + chart: {{ template "fileshare.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ template "fileshare.name" . }} + release: {{ .Release.Name }} diff --git a/practice/helm/fileshare/values.yaml b/practice/helm/fileshare/values.yaml new file mode 100644 index 0000000..ef52561 --- /dev/null +++ b/practice/helm/fileshare/values.yaml @@ -0,0 +1,36 @@ +# Default values for fileshare. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: reloadable-nginx + tag: 1.12 + pullPolicy: IfNotPresent + +persistence: + enabled: true + size: 1Gi + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + path: / + hosts: + - my.host.foo + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi diff --git a/practice/kube-basics-practice/Dockerfile b/practice/kube-basics-practice/Dockerfile new file mode 100644 index 0000000..315c4e1 --- /dev/null +++ b/practice/kube-basics-practice/Dockerfile @@ -0,0 +1,10 @@ +FROM nginx:1.12 + +RUN set -ex && \ + apt-get update && \ + apt-get install -y procps && \ + apt-get clean + +COPY docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/practice/kube-basics-practice/docker-entrypoint.sh b/practice/kube-basics-practice/docker-entrypoint.sh new file mode 100755 index 0000000..467a525 --- /dev/null +++ b/practice/kube-basics-practice/docker-entrypoint.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +DIR="etc/nginx/" + +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' + + +log() { + case $1 in + error) + LOG_LEVEL="error" + COLOR=$RED + ;; + notice) + LOG_LEVEL="notice" + COLOR=$GREEN + ;; + esac + + timestamp="$(date +"%Y/%m/%d %H:%M:%S")" + echo -e "$timestamp [$LOG_LEVEL] $0: ${COLOR}$2${NC}" +} + +getmd5() { + tar --strip-components=2 -C / -cf - $DIR | md5sum | awk '{print $1}' +} + + +if [ ! -d $DIR ]; then + log error "/$DIR not found" + exit 1 +fi + +if ! [ -x "$(command -v nginx)" ]; then + log error "Nginx is not installed" + exit 1 +fi + +log notice "starting Nginx process..." +nginx + +log notice "watching /$DIR for changes..." +checksum_initial=$(getmd5) + +trap "exit 0" SIGINT SIGTERM +while true; do + ps aux | grep 'master process nginx' | grep -q -v grep + NGINX_STATUS=$? + if [ $NGINX_STATUS -ne 0 ]; then + log error "Nginx exited. Stopping entrypoint script..." + exit 1 + fi + checksum_current=$(getmd5) + if [ "$checksum_initial" != "$checksum_current" ]; then + checksum_initial=$checksum_current + + nginx -tq + NGINX_CONF_STATUS=$? + if [ $NGINX_CONF_STATUS -ne 0 ]; then + log error "couldn't reload Nginx due to an error in the config file" + continue + fi + + nginx -s reload + log notice "reloaded Nginx config" + fi + sleep 5 +done diff --git a/practice/kube-basics-practice/kube/configmap.yaml b/practice/kube-basics-practice/kube/configmap.yaml new file mode 100644 index 0000000..633a517 --- /dev/null +++ b/practice/kube-basics-practice/kube/configmap.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: fileshare +data: + default.conf: | + server { + listen 80 default_server; + server_name _; + + location / { + return 200 '$hostname\n'; + } + + location /files { + alias /data; + autoindex on; + client_body_temp_path /tmp; + dav_methods PUT DELETE MKCOL COPY MOVE; + create_full_put_path on; + dav_access user:rw group:rw all:r; + } + } diff --git a/practice/kube-basics-practice/kube/deployment.yaml b/practice/kube-basics-practice/kube/deployment.yaml new file mode 100644 index 0000000..202e7f6 --- /dev/null +++ b/practice/kube-basics-practice/kube/deployment.yaml @@ -0,0 +1,60 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: fileshare +spec: + replicas: 2 + selector: + matchLabels: + app: fileshare + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate + template: + metadata: + labels: + app: fileshare + spec: + containers: + - image: reloadable-nginx:1.12 + name: nginx + ports: + - containerPort: 80 + readinessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 80 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 80 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + initialDelaySeconds: 10 + resources: + requests: + cpu: 100m + memory: 100Mi + limits: + cpu: 100m + memory: 100Mi + volumeMounts: + - name: config + mountPath: /etc/nginx/conf.d + - name: data + mountPath: /data + volumes: + - name: config + configMap: + name: fileshare + - name: data + persistentVolumeClaim: + claimName: fileshare diff --git a/practice/kube-basics-practice/kube/ingress.yaml b/practice/kube-basics-practice/kube/ingress.yaml new file mode 100644 index 0000000..cc1604f --- /dev/null +++ b/practice/kube-basics-practice/kube/ingress.yaml @@ -0,0 +1,12 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: fileshare +spec: + rules: + - host: my.host.foo + http: + paths: + - backend: + serviceName: fileshare + servicePort: 80 diff --git a/practice/kube-basics-practice/kube/pvc.yaml b/practice/kube-basics-practice/kube/pvc.yaml new file mode 100644 index 0000000..198cac9 --- /dev/null +++ b/practice/kube-basics-practice/kube/pvc.yaml @@ -0,0 +1,10 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: fileshare +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi diff --git a/practice/kube-basics-practice/kube/service.yaml b/practice/kube-basics-practice/kube/service.yaml new file mode 100644 index 0000000..c8afbc8 --- /dev/null +++ b/practice/kube-basics-practice/kube/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: fileshare +spec: + ports: + - port: 80 + targetPort: 80 + selector: + app: fileshare + type: ClusterIP diff --git a/practice/kube-basics/configmap.yaml b/practice/kube-basics/configmap.yaml new file mode 100644 index 0000000..302ddc5 --- /dev/null +++ b/practice/kube-basics/configmap.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: my-configmap +data: + default.conf: | + server { + listen 80 default_server; + server_name _; + + location / { + return 200 '$hostname\n'; + } + } diff --git a/practice/kube-basics/deployment-with-configmap.yaml b/practice/kube-basics/deployment-with-configmap.yaml new file mode 100644 index 0000000..ad66a18 --- /dev/null +++ b/practice/kube-basics/deployment-with-configmap.yaml @@ -0,0 +1,55 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: my-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: my-app + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate + template: + metadata: + labels: + app: my-app + spec: + containers: + - image: nginx:1.12 + name: nginx + ports: + - containerPort: 80 + readinessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 80 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 80 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + initialDelaySeconds: 10 + resources: + requests: + cpu: 100m + memory: 100Mi + limits: + cpu: 100m + memory: 100Mi + volumeMounts: + - name: config + mountPath: /etc/nginx/conf.d/ + volumes: + - name: config + configMap: + name: my-configmap diff --git a/practice/kube-basics/deployment-with-stuff.yaml b/practice/kube-basics/deployment-with-stuff.yaml new file mode 100644 index 0000000..d28f901 --- /dev/null +++ b/practice/kube-basics/deployment-with-stuff.yaml @@ -0,0 +1,48 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: my-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: my-app + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate + template: + metadata: + labels: + app: my-app + spec: + containers: + - image: nginx:1.12 + name: nginx + ports: + - containerPort: 80 + readinessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 80 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 80 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + initialDelaySeconds: 10 + resources: + requests: + cpu: 100m + memory: 100Mi + limits: + cpu: 100m + memory: 100Mi diff --git a/practice/kube-basics/deployment.yaml b/practice/kube-basics/deployment.yaml new file mode 100644 index 0000000..a86fc7c --- /dev/null +++ b/practice/kube-basics/deployment.yaml @@ -0,0 +1,24 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: my-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: my-app + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate + template: + metadata: + labels: + app: my-app + spec: + containers: + - image: nginx:1.12 + name: nginx + ports: + - containerPort: 80 diff --git a/practice/kube-basics/ingress.yaml b/practice/kube-basics/ingress.yaml new file mode 100644 index 0000000..f7ae377 --- /dev/null +++ b/practice/kube-basics/ingress.yaml @@ -0,0 +1,12 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: my-ingress +spec: + rules: + - host: my.host.foo + http: + paths: + - backend: + serviceName: my-service + servicePort: 80 diff --git a/practice/kube-basics/pod.yaml b/practice/kube-basics/pod.yaml new file mode 100644 index 0000000..a15a37b --- /dev/null +++ b/practice/kube-basics/pod.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + name: my-pod + labels: + app: my-app +spec: + containers: + - image: nginx:1.12 + name: nginx + ports: + - containerPort: 80 diff --git a/practice/kube-basics/pvc.yaml b/practice/kube-basics/pvc.yaml new file mode 100644 index 0000000..769cb24 --- /dev/null +++ b/practice/kube-basics/pvc.yaml @@ -0,0 +1,10 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: my-claim +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi diff --git a/practice/kube-basics/replicaset.yaml b/practice/kube-basics/replicaset.yaml new file mode 100644 index 0000000..2095ad4 --- /dev/null +++ b/practice/kube-basics/replicaset.yaml @@ -0,0 +1,19 @@ +apiVersion: extensions/v1beta1 +kind: ReplicaSet +metadata: + name: my-replicaset-2 +spec: + replicas: 0 + selector: + matchLabels: + app: my-app + template: + metadata: + labels: + app: my-app + spec: + containers: + - image: nginx:1.13 + name: nginx + ports: + - containerPort: 80 diff --git a/practice/kube-basics/service.yaml b/practice/kube-basics/service.yaml new file mode 100644 index 0000000..581b3fc --- /dev/null +++ b/practice/kube-basics/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: my-service +spec: + ports: + - port: 80 + targetPort: 80 + selector: + app: my-app + type: ClusterIP