liveBook · Manning

Kubectl apply

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

kubectl apply is a Kubernetes command that creates or updates cluster resources from declarative configuration files or manifests.

kubectl apply creates or updates Kubernetes resources from declarative YAML configuration files. It turns deployment manifests into running objects such as deployments, pods, and services. section 6.8.5 section 6.8.9

Deploy a local microservice

From the directory containing the manifest, run `kubectl apply -f scripts/deploy.yaml`. Successful output reports created resources, such as `deployment.apps/video-streaming created` and `service/video-streaming created`. section 6.8.5

Validate and iterate after applying a manifest:

  • Run `kubectl get pods` to confirm the pod reaches `Running` status. section 6.8.5
  • Run `kubectl get deployments` and `kubectl get services` to check readiness and exposed ports. section 6.8.5
  • After rebuilding an updated Docker image with a new version number, run kubectl apply again to deploy the change. section 6.8.6
  • Use an infrastructure script to apply stable MongoDB and RabbitMQ configurations once at cluster setup. section 10.10.3
cd chapter-10/scripts/local-kub
./deploy.sh

A local deployment script combines Docker image builds with kubectl apply calls for multiple microservices and their YAML configurations. section 10.8.2

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Demonstrates manifest application, status validation, port checking, and repeated updates without detailing kubectl internals.
Examples
Uses a video-streaming microservice, FlixTube microservices, and MongoDB and RabbitMQ infrastructure as deployment examples.
What it assumes
Assumes a connected Kubernetes cluster, Docker-built images, and YAML configuration files describing the desired resources.
What you can do after
Operate Kubernetes deployments by applying manifests, checking resource status, verifying service ports, and rolling out rebuilt images.
How it connects
Connects Docker images and YAML manifests with Kubernetes deployments, pods, services, infrastructure, and local deployment scripts.

Also explained in

Compare how 6 books explain kubectl apply →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.