Skip to main content

Getting Started with Kubernetes

A step-by-step tutorial for deploying your first application on Kubernetes using kubectl and manifests.

kubernetescontainersbeginner

Prerequisites

Before you begin, make sure you have the following installed:

  • kubectl - The Kubernetes command-line tool
  • minikube or access to a Kubernetes cluster
  • Docker - For building container images

Step 1: Start Your Cluster

If you’re using minikube, start a local cluster:

minikube start

Verify the cluster is running:

kubectl cluster-info

Step 2: Create a Deployment

Create a file called deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-app
  labels:
    app: hello
spec:
  replicas: 2
  selector:
    matchLabels:
      app: hello
  template:
    metadata:
      labels:
        app: hello
    spec:
      containers:
        - name: hello
          image: gcr.io/google-samples/hello-app:1.0
          ports:
            - containerPort: 8080

Apply the deployment:

kubectl apply -f deployment.yaml

Step 3: Expose the Service

Create a Service to make your application accessible:

kubectl expose deployment hello-app --type=NodePort --port=8080

Step 4: Verify Everything Works

Check the status of your pods:

kubectl get pods
kubectl get services

Access your application:

minikube service hello-app

Next Steps