☀️
Yellow Team
  • Welcome
    • Welcome
  • Training
    • Cloud Academy
      • Azure
        • Azure Sentinel Incident Triage Challenge
      • Kubernetes
        • Mastering Kubernetes Pod Configuration: Defining Resource Requirements
        • Mastering Kubernetes Pod Configuration: Security Contexts
        • Mastering Kubernetes Pod Configuration: Persistent Data
        • Mastering Kubernetes Pod Configuration: Config Maps and Secrets
        • Mastering Kubernetes Pod Configuration: Service Accounts
        • Create Kubernetes Nginx Ingress Controller for External API Traffic
        • Create Kubernetes Layer-7 Network Policies using Cilium CNI
    • Cloud Guru
      • Certified Kubernetes Administrator (CKA)
        • Certified Kubernetes Administrator (CKA) Practice Exam: Part 1
        • Certified Kubernetes Administrator (CKA) Practice Exam: Part 2
        • Certified Kubernetes Administrator (CKA) Practice Exam: Part 3
        • Certified Kubernetes Administrator (CKA) Practice Exam: Part 4
      • Introduction to Kubernetes
        • Building a Kubernetes 1.27 Cluster with kubeadm
        • Working with Kubernetes Using kubectl
        • Running Containers with Kubernetes
      • Kubernetes Essentials
        • Deploying a Simple Service to Kubernetes
        • Deploying a Microservice Application to Kubernetes
      • Learn Kubernetes by Doing
        • Creating a Kubernetes Cluster
        • Deploying a Pod to a Node with a Label in Kubernetes
        • Creating a Service and Discovering DNS Names in Kubernetes
        • Scheduling Pods with Taints and Tolerations in Kubernetes
      • AWS
        • Creating an AWS CodeCommit Repository That Triggers Email Notifications
      • Docker
        • Deploying a Docker Container with Jenkins Pipelines
Powered by GitBook
On this page
  • Create a store-products service and verify that you can access it from the busybox testing pod.
  1. Training
  2. Cloud Guru
  3. Kubernetes Essentials

Deploying a Simple Service to Kubernetes

Create a deployment for the store-products service with four replicas.

Create the deployment with four replicas:

cat << EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: store-products
  labels:
    app: store-products
spec:
  replicas: 4
  selector:
    matchLabels:
      app: store-products
  template:
    metadata:
      labels:
        app: store-products
    spec:
      containers:
      - name: store-products
        image: linuxacademycontent/store-products:1.0.0
        ports:
        - containerPort: 80
EOF

Create a store-products service and verify that you can access it from the busybox testing pod.

Create a service for the store-products pods:

cat << EOF | kubectl apply -f -
kind: Service
apiVersion: v1
metadata:
  name: store-products
spec:
  selector:
    app: store-products
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
EOF

Make sure the service is up in the cluster:

kubectl get svc store-products
curl http://$ClusterIP

Use kubectl exec to query the store-products service from the busybox testing pod.

kubectl exec busybox -- curl -s store-products

PreviousKubernetes EssentialsNextDeploying a Microservice Application to Kubernetes

Last updated 1 year ago