Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Kubernetes Service Example Programs

Here’s a complete YAML file that contains three Deployments and their corresponding Services:

  1. ClusterIP (default) for scmgalaxy/nginx-devopsschoolv1
  2. NodePort for scmgalaxy/nginx-devopsschoolv2
  3. LoadBalancer for rajeshmode/honda-gallery

Each container runs on port 80.

dasdsad
dsadsadsad
dsad
dsa
dsad
sa

βœ… Full Kubernetes YAML (deployment-and-services.yaml)

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-clusterip
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx-clusterip
  template:
    metadata:
      labels:
        app: nginx-clusterip
    spec:
      containers:
      - name: nginx
        image: scmgalaxy/nginx-devopsschoolv1
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: nginx-clusterip-svc
spec:
  type: ClusterIP
  selector:
    app: nginx-clusterip
  ports:
  - port: 80
    targetPort: 80

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-nodeport
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx-nodeport
  template:
    metadata:
      labels:
        app: nginx-nodeport
    spec:
      containers:
      - name: nginx
        image: scmgalaxy/nginx-devopsschoolv2
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: nginx-nodeport-svc
spec:
  type: NodePort
  selector:
    app: nginx-nodeport
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30080  # You can change this to a valid port range 30000–32767

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: honda-loadbalancer
spec:
  replicas: 2
  selector:
    matchLabels:
      app: honda-loadbalancer
  template:
    metadata:
      labels:
        app: honda-loadbalancer
    spec:
      containers:
      - name: honda
        image: rajeshmode/honda-gallery
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: honda-loadbalancer-svc
spec:
  type: LoadBalancer
  selector:
    app: honda-loadbalancer
  ports:
  - port: 80
    targetPort: 80
Code language: PHP (php)

πŸš€ Usage

To apply this YAML:

kubectl apply -f deployment-and-services.yaml
Code language: CSS (css)

You can then verify:

kubectl get all
Code language: JavaScript (javascript)

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.