Skip to content

Instantly share code, notes, and snippets.

@arthursvpb
Created December 13, 2023 11:13
Show Gist options
  • Save arthursvpb/ba72499bce2791f9950cefbde127481b to your computer and use it in GitHub Desktop.
Save arthursvpb/ba72499bce2791f9950cefbde127481b to your computer and use it in GitHub Desktop.
This YAML file is designed to be a quickstart for deploying an Nginx web server in a Kubernetes cluster.
# Define a new Namespace for our test environment
apiVersion: v1
kind: Namespace
metadata:
name: quickstart-test
---
# Deployment definition starts here
apiVersion: apps/v1
kind: Deployment
metadata:
# Name of the Deployment
name: nginx-deployment
# Namespace in which this Deployment will be created
namespace: quickstart-test
spec:
# Number of pod replicas
replicas: 2
# Label selector for managing the pods
selector:
matchLabels:
app: nginx
# Template for the pods
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
# Docker image to use for the container
image: nginx:latest
# Ports exposed by the container
ports:
- containerPort: 80
---
# Service definition starts here
apiVersion: v1
kind: Service
metadata:
# Name of the Service
name: nginx-service
# Namespace in which this Service will be created
namespace: quickstart-test
spec:
# Type of Service - NodePort makes it accessible externally
type: NodePort
# Selector to link the Service to the Deployment
selector:
app: nginx
# Port configuration
ports:
- protocol: TCP
# Port to be exposed on the pod
port: 80
# Port to be exposed on the node
nodePort: 30007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment