☀️
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 an nginx deployment, and verify it was successful
  • Create a service, and verify the service was successful
  • Create a pod that will allow you to query DNS, and verify it’s been created
  • Perform a DNS query to the service
  • Record the DNS name
  1. Training
  2. Cloud Guru
  3. Learn Kubernetes by Doing

Creating a Service and Discovering DNS Names in Kubernetes

PreviousDeploying a Pod to a Node with a Label in KubernetesNextScheduling Pods with Taints and Tolerations in Kubernetes

Last updated 1 year ago

Create an nginx deployment, and verify it was successful

Use this command to create an nginx deployment:

kubectl run nginx --image=nginx

Use this command to verify deployment was successful:

kubectl get deployments

Create a service, and verify the service was successful

Use this command to create a service:

kubectl expose deployment nginx --port 80 --type NodePort

Use this command to verify the service was created:

kubectl get services

Create a pod that will allow you to query DNS, and verify it’s been created

Use the following YAML to create the busybox pod spec:

busybox.yaml

apiVersion: v1
kind: Pod
metadata:
  name: busybox
spec:
  containers:
  - image: busybox:1.28.4
    command:
      - sleep
      - "3600"
    name: busybox
  restartPolicy: Always

Use the following command to create the busybox pod:

kubectl create -f busybox.yaml

Use the following command to verify the pod was created successfully:

kubectl get pods

Perform a DNS query to the service

Use the following command to query the DNS name of the nginx service:

kubectl exec busybox -- nslookup nginx

Record the DNS name

Record the name: