From 35ec9257e2c4ddc00d7c4baa9e00e2147fac583e Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Fri, 22 Nov 2024 10:46:08 +0100 Subject: [PATCH] Primer commit --- NginxEjemplo/lanza.sh | 1 + NginxHelloWorld/Dockerfile | 8 +++++ NginxHelloWorld/buildconfig.yaml | 25 +++++++++++++ NginxHelloWorld/creaTodo.sh | 6 ++++ NginxHelloWorld/deployment.yaml | 25 +++++++++++++ NginxHelloWorld/deployment2.yaml | 31 ++++++++++++++++ NginxHelloWorld/index.html | 2 ++ NginxHelloWorld/nginx.conf | 61 ++++++++++++++++++++++++++++++++ NginxHelloWorld/paraTodo.sh | 5 +++ NginxHelloWorld/route.yaml | 16 +++++++++ NginxHelloWorld/service.yaml | 16 +++++++++ 11 files changed, 196 insertions(+) create mode 100644 NginxEjemplo/lanza.sh create mode 100644 NginxHelloWorld/Dockerfile create mode 100644 NginxHelloWorld/buildconfig.yaml create mode 100644 NginxHelloWorld/creaTodo.sh create mode 100644 NginxHelloWorld/deployment.yaml create mode 100644 NginxHelloWorld/deployment2.yaml create mode 100644 NginxHelloWorld/index.html create mode 100644 NginxHelloWorld/nginx.conf create mode 100644 NginxHelloWorld/paraTodo.sh create mode 100644 NginxHelloWorld/route.yaml create mode 100644 NginxHelloWorld/service.yaml diff --git a/NginxEjemplo/lanza.sh b/NginxEjemplo/lanza.sh new file mode 100644 index 0000000..ae5ec4c --- /dev/null +++ b/NginxEjemplo/lanza.sh @@ -0,0 +1 @@ +oc run nginx-app --image=nginxinc/nginx-unprivileged:1.23.2 diff --git a/NginxHelloWorld/Dockerfile b/NginxHelloWorld/Dockerfile new file mode 100644 index 0000000..2e1ce25 --- /dev/null +++ b/NginxHelloWorld/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:latest +RUN apt update && \ + apt install -y nginx vim + +COPY index.html /usr/share/nginx/html +COPY nginx.conf /etc/nginx/nginx.conf + +CMD /usr/sbin/nginx -g 'daemon off;' diff --git a/NginxHelloWorld/buildconfig.yaml b/NginxHelloWorld/buildconfig.yaml new file mode 100644 index 0000000..02515b1 --- /dev/null +++ b/NginxHelloWorld/buildconfig.yaml @@ -0,0 +1,25 @@ +apiVersion: build.openshift.io/v1 +kind: BuildConfig +metadata: + name: nginx-hello-world +spec: + runPolicy: Serial + source: + dockerfile: | + FROM ubuntu:latest + RUN apt update && \ + apt install -y nginx + + COPY index.html /usr/share/nginx/html + COPY nginx.conf /etc/nginx/nginx.conf + + CMD /usr/sbin/nginx -g 'daemon off;' + + strategy: + type: Docker + dockerStrategy: + noCache: false + output: + to: + kind: ImageStreamTag + name: "nginx-hello-world:latest" diff --git a/NginxHelloWorld/creaTodo.sh b/NginxHelloWorld/creaTodo.sh new file mode 100644 index 0000000..0abea50 --- /dev/null +++ b/NginxHelloWorld/creaTodo.sh @@ -0,0 +1,6 @@ +oc create -f buildconfig.yaml +oc create imagestream nginx-hello-world +oc start-build nginx-hello-world --from-dir=./ --follow +oc create -f deployment2.yaml +oc create -f service.yaml +oc create -f route.yaml diff --git a/NginxHelloWorld/deployment.yaml b/NginxHelloWorld/deployment.yaml new file mode 100644 index 0000000..36530a6 --- /dev/null +++ b/NginxHelloWorld/deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-hello-world + labels: + app: nginx-hello-world +spec: + replicas: 3 + selector: + matchLabels: + app: nginx-hello-world + template: + metadata: + labels: + app: nginx-hello-world + spec: + containers: + - name: nginx + image: "image-registry.openshift-image-registry.svc:5000/miproyecto/nginx-hello-world" + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + tty: true + stdin: true + serviceAccount: default + terminationGracePeriodSeconds: 5 diff --git a/NginxHelloWorld/deployment2.yaml b/NginxHelloWorld/deployment2.yaml new file mode 100644 index 0000000..4bcd15f --- /dev/null +++ b/NginxHelloWorld/deployment2.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-hello-world + labels: + app: nginx-hello-world +spec: + replicas: 1 + selector: + matchLabels: + app: nginx-hello-world + template: + metadata: + labels: + app: nginx-hello-world + spec: + containers: + - name: nginx-hello-world + image: "image-registry.openshift-image-registry.svc:5000/miproyecto/nginx-hello-world" + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + tty: true + stdin: true + serviceAccount: default + volumeMounts: + - mountPath: /usr/share/nginx/html + name: html-volume + volumes: + - name: html-volume + persistentVolumeClaim: + claimName: miproyecto-claim diff --git a/NginxHelloWorld/index.html b/NginxHelloWorld/index.html new file mode 100644 index 0000000..353571d --- /dev/null +++ b/NginxHelloWorld/index.html @@ -0,0 +1,2 @@ +

Hello, World!

+

I'm running in openshift

diff --git a/NginxHelloWorld/nginx.conf b/NginxHelloWorld/nginx.conf new file mode 100644 index 0000000..9ddc158 --- /dev/null +++ b/NginxHelloWorld/nginx.conf @@ -0,0 +1,61 @@ +user nginx; +worker_processes auto; +error_log /tmp/error.log; +pid /tmp/nginx.pid; + +# Load dynamic modules. See /usr/share/nginx/README.dynamic. +include /usr/share/nginx/modules/*.conf; + +events { + worker_connections 1024; +} + +http { + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /tmp/access.log main; + + client_body_temp_path /tmp/nginx 1 2; + proxy_temp_path /tmp/nginx-proxy; + fastcgi_temp_path /tmp/nginx-fastcgi; + uwsgi_temp_path /tmp/nginx-uwsgi; + scgi_temp_path /tmp/nginx-scgi; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Load modular configuration files from the /etc/nginx/conf.d directory. + # See http://nginx.org/en/docs/ngx_core_module.html#include + # for more information. + include /etc/nginx/conf.d/*.conf; + + server { + listen 8080 default_server; + listen [::]:8080 default_server; + server_name _; + root /usr/share/nginx/html; + + # Load configuration files for the default server block. + include /etc/nginx/default.d/*.conf; + + location / { + } + + error_page 404 /404.html; + location = /40x.html { + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + } + } +} + diff --git a/NginxHelloWorld/paraTodo.sh b/NginxHelloWorld/paraTodo.sh new file mode 100644 index 0000000..8a9a9ac --- /dev/null +++ b/NginxHelloWorld/paraTodo.sh @@ -0,0 +1,5 @@ +oc delete buildconfig nginx-hello-world +oc delete imagestream nginx-hello-world +oc delete deployment nginx-hello-world +oc delete service nginx-hello-world +oc delete route nginx-hello-world diff --git a/NginxHelloWorld/route.yaml b/NginxHelloWorld/route.yaml new file mode 100644 index 0000000..879c77a --- /dev/null +++ b/NginxHelloWorld/route.yaml @@ -0,0 +1,16 @@ +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + name: nginx-hello-world +spec: + # hostname: foo.apps.CLUSTER.ccs.ornl.gov + port: + targetPort: nginx + tls: + insecureEdgeTerminationPolicy: Redirect + termination: edge + to: + kind: Service + name: nginx-hello-world + weight: 100 + wildcardPolicy: None diff --git a/NginxHelloWorld/service.yaml b/NginxHelloWorld/service.yaml new file mode 100644 index 0000000..0bf458d --- /dev/null +++ b/NginxHelloWorld/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: nginx-hello-world + name: nginx-hello-world +spec: + ports: + - name: nginx + port: 80 + protocol: TCP + targetPort: 8080 + selector: + app: nginx-hello-world + sessionAffinity: None + type: ClusterIP