Verifying Kubernetes Deployment Creation
Creating a Kubernetes Deployment
To create a Kubernetes Deployment, you can use the kubectl create
command with a YAML configuration file. Here's an example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-container
image: nginx:latest
ports:
- containerPort: 80
You can save this configuration to a file (e.g., deployment.yaml
) and then create the Deployment using the following command:
kubectl create -f deployment.yaml
Verifying Deployment Creation
After creating a Deployment, you can verify its creation using the following commands:
-
List all Deployments:
kubectl get deployments
This will display all the Deployments in your Kubernetes cluster, including the newly created my-deployment
.
-
Describe the Deployment:
kubectl describe deployment my-deployment
This will provide detailed information about the my-deployment
, including the number of replicas, the container image, and any associated metadata.
-
Check the Deployment's status:
kubectl get deployment my-deployment -o yaml
This will output the YAML representation of the my-deployment
, which includes its status, the number of available and ready Pods, and other details.
You can also use the LabEx CLI to verify the Deployment creation:
labex get deployments
labex describe deployment my-deployment
The LabEx CLI provides a user-friendly interface for interacting with your Kubernetes cluster and verifying the creation of resources.