diff --git a/kubernetes-volumes/cm.yaml b/kubernetes-volumes/cm.yaml new file mode 100644 index 0000000..d66e47b --- /dev/null +++ b/kubernetes-volumes/cm.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-conf + namespace: homework +data: + nginx.conf: | + server { + listen 8000; + root /homework; + autoindex on; + } +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: my-configmap + namespace: homework +data: + test: "123" diff --git a/kubernetes-volumes/deployment.yaml b/kubernetes-volumes/deployment.yaml new file mode 100644 index 0000000..19a7666 --- /dev/null +++ b/kubernetes-volumes/deployment.yaml @@ -0,0 +1,65 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx + labels: + app: nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:stable + ports: + - containerPort: 8000 + volumeMounts: + - mountPath: /homework + name: html + - mountPath: /etc/nginx/conf.d/ + name: nginx-conf + - mountPath: /homework/conf + name: my-configmap + lifecycle: + preStop: + exec: + command: + - "rm" + - "/homework/index.html" + readinessProbe: + httpGet: + path: /index.html + port: 8000 + initialDelaySeconds: 5 + periodSeconds: 5 + initContainers: + - name: install + image: busybox:stable + command: + - wget + - "-O" + - "/init/index.html" + - http://github.com + volumeMounts: + - name: html + mountPath: "/init" + volumes: + - name: nginx-conf + configMap: + name: nginx-conf + - name: my-configmap + configMap: + name: my-configmap + - name: html + persistentVolumeClaim: + claimName: nginx-html-pvc diff --git a/kubernetes-volumes/ingress.yaml b/kubernetes-volumes/ingress.yaml new file mode 100644 index 0000000..7e5359b --- /dev/null +++ b/kubernetes-volumes/ingress.yaml @@ -0,0 +1,26 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: nginx-ingress + namespace: homework + annotations: + nginx.ingress.kubernetes.io/rewrite-target: /$1 +spec: + rules: + - host: homework.otus + http: + paths: + - path: /homepage + pathType: Prefix + backend: + service: + name: nginx-service + port: + number: 8000 + - path: /(.*) + pathType: ImplementationSpecific + backend: + service: + name: nginx-service + port: + number: 8000 \ No newline at end of file diff --git a/kubernetes-volumes/namespace.yaml b/kubernetes-volumes/namespace.yaml new file mode 100644 index 0000000..8fed436 --- /dev/null +++ b/kubernetes-volumes/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: homework \ No newline at end of file diff --git a/kubernetes-volumes/pvc.yaml b/kubernetes-volumes/pvc.yaml new file mode 100644 index 0000000..d80faef --- /dev/null +++ b/kubernetes-volumes/pvc.yaml @@ -0,0 +1,12 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: nginx-html-pvc + namespace: homework +spec: + storageClassName: custom-sc + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi \ No newline at end of file diff --git a/kubernetes-volumes/sc.yaml b/kubernetes-volumes/sc.yaml new file mode 100644 index 0000000..4f6612f --- /dev/null +++ b/kubernetes-volumes/sc.yaml @@ -0,0 +1,8 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: custom-sc + namespace: homework +provisioner: k8s.io/minikube-hostpath +reclaimPolicy: Retain +volumeBindingMode: Immediate \ No newline at end of file diff --git a/kubernetes-volumes/service.yaml b/kubernetes-volumes/service.yaml new file mode 100644 index 0000000..384562f --- /dev/null +++ b/kubernetes-volumes/service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: nginx-service +spec: + ports: + - port: 8000 + targetPort: 8000 + selector: + app: nginx \ No newline at end of file