• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Docker

How to Manage Kubernetes Containers

July 8, 2024
in Docker, Docker Commands Examples, Docker Commands Tutorial, Docker Tutorial
A A
0
11
SHARES
101
VIEWS
Share on FacebookShare on Twitter

This post will cover topic related to ‘How to Manage Kubernetes Containers’ with multiple docker command examples and different scenerios. So this will help you to understand the command docker and options available in it. Also this post will explain you how to use docker command.

In Docker, managing containers is crucial for deploying and orchestrating applications. Kubernetes, a powerful container orchestration platform, plays a key role in managing these containers efficiently.

Let’s explore various commands related to managing Kubernetes containers:

1. Creating a Kubernetes Pod:
To create a pod named “nginx” with a single container running Nginx:

docker run --name nginx-pod --image nginx

This command creates a new pod with the Nginx container inside. Verify by checking the pod status:

kubectl get pods

Output example:

    NAME        READY   STATUS    RESTARTS   AGE
    nginx-pod   1/1     Running   0          30s
    

2. Inspecting a Pod:
To get detailed information about a specific pod:

kubectl describe pod nginx-pod

This command provides comprehensive details about the pod, including its IP address, status, and associated events.

3. Deleting a Pod:
To delete a pod named “nginx-pod”:

kubectl delete pod nginx-pod

Verify deletion by listing all pods:

kubectl get pods

Output example showing no pods:

    No resources found in default namespace.
    

4. Scaling Deployments:
To scale a deployment named “myapp” to 3 replicas:

kubectl scale --replicas=3 deployment/myapp

This scales the number of replicas of the “myapp” deployment to 3 instances.

5. Updating Container Image:
To update the image of a deployment “myapp” to a new version:

kubectl set image deployment/myapp nginx=nginx:1.19

This updates the Nginx container in the “myapp” deployment to version 1.19. Verify by checking deployment status:

kubectl rollout status deployment/myapp

Output example showing rollout complete:

    deployment "myapp" successfully rolled out
    

6. Executing Commands in Containers:
To execute a shell command inside a running container “nginx-pod”:

kubectl exec -it nginx-pod -- /bin/bash

This opens an interactive shell session inside the “nginx-pod” container, allowing command execution and verification of container state and logs.

7. Port Forwarding:
To forward a local port to a port in a pod “nginx-pod”:

kubectl port-forward nginx-pod 8080:80

This command forwards local port 8080 to port 80 of the “nginx-pod”, enabling direct access to the pod’s service.

8. Viewing Logs:
To view logs of a container “nginx” in pod “nginx-pod”:

kubectl logs nginx-pod -c nginx

This retrieves the logs generated by the “nginx” container within the “nginx-pod”, aiding in troubleshooting and monitoring.

9. Applying Resource Configuration:
To apply a YAML file defining a pod configuration:

kubectl apply -f pod.yaml

Where “pod.yaml” contains the pod configuration details. Verify by checking pod status:

kubectl get pods

Output example showing the newly created pod:

    NAME          READY   STATUS    RESTARTS   AGE
    nginx-pod     1/1     Running   0          1m
    

10. Monitoring Pod Resource Usage:
To view CPU and memory usage of pods:

kubectl top pod nginx-pod

This command displays resource usage metrics for the “nginx-pod”, helping in performance monitoring and capacity planning.

Also check similar articles.

How to Manage Kubernetes Container Checkpoints
How to Manage Kubernetes Build Processes
Search Kubernetes for Docker Images
Log out from Kubernetes Registry
Log in to Kubernetes Registry

Tags: DockerDocker Commands ExamplesDocker Commands TutorialDocker Tutorial
Previous Post

How to Manage Kubernetes Container Checkpoints

Next Post

How to Manage Kubernetes Contexts

Related You may like!

howto

Managing Swarm Services

August 21, 2024
howto

Managing Docker Volumes

August 21, 2024

Managing Docker Networks

August 21, 2024

Managing Swarm Secrets

July 8, 2024

Managing Swarm Nodes

July 8, 2024

Managing Swarm Configurations

July 8, 2024
Next Post
howto

How to Manage Kubernetes Contexts

howto

How to Manage Kubernetes Images

howto

How to Manage Kubernetes Image Manifests

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Using BTRFS Subvolume for User Home Directory in Linux

    22 shares
    Share 9 Tweet 6
  • Downloading Docker Images from a Registry

    13 shares
    Share 5 Tweet 3
  • Configuring SSL Connection Mode in mysqldump

    17 shares
    Share 7 Tweet 4
  • Omit Tablespace Information in mysqldump Output

    13 shares
    Share 5 Tweet 3
  • Setting MySQL Dump Compatibility Mode

    18 shares
    Share 7 Tweet 5
  • Setting Network Buffer Length in mysqldump

    13 shares
    Share 5 Tweet 3
  • Logging out from Docker Registries

    13 shares
    Share 5 Tweet 3
  • Scheduling Nodes in Kubernetes with kubectl uncordon

    12 shares
    Share 5 Tweet 3
  • Managing Default User Creation Settings in Linux

    15 shares
    Share 6 Tweet 4
  • Using Extended INSERT Syntax in mysqldump

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.