Skip to content

Instantly share code, notes, and snippets.

@monodot
Last active December 19, 2024 15:01
Show Gist options
  • Select an option

  • Save monodot/98a0dc7bb1ab231d3447ad416f62f95a to your computer and use it in GitHub Desktop.

Select an option

Save monodot/98a0dc7bb1ab231d3447ad416f62f95a to your computer and use it in GitHub Desktop.
Deploy nginx on OpenShift - example

OpenShift Example: Deploy nginx web server by creating resources from YAML files

Let's deploy nginx!

We'll create a Deployment, a Service and a Route. 🥔🥔

  1. We create a Deployment to run the nginx-unprivileged image (this Nginx image doesn't run nginx as root - because OpenShift doesn't like that!)
  2. We create a Service which load balances between the pods in the Deployment.
  3. We create a Route which forwards traffic onto the Service, and the Pods!

Add each of these YAMLs to the cluster, using the web console or using oc apply -f <filename.yml>.

And.... VOILA.

Angela being fabulous

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginxinc/nginx-unprivileged:1.18
ports:
- containerPort: 8080
kind: Service
apiVersion: v1
metadata:
name: nginx
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 8080
targetPort: 8080
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: nginx
spec:
to:
kind: Service
name: nginx
weight: 100
port:
targetPort: 8080
tls:
termination: edge
@monodot
Copy link
Author

monodot commented Dec 19, 2024

@ravi557 Thanks for reporting - did you find out the root cause here? e.g. kubectl describe pod ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment