Introduction
Kubernetes is an open-source platform designed to automate deploying, scaling, and operating application containers. In this guide, you will learn how to create your first deployment on a Kubernetes cluster. This setup can be effectively hosted on a Windows VPS UK for optimal performance.
Prerequisites
- A Kubernetes cluster up and running (can be a local cluster like Minikube or a cloud-based cluster)
- kubectl installed on your local machine
- Basic knowledge of Linux commands and YAML syntax
Step 1: Verify Kubernetes Cluster
Check if your Kubernetes cluster is running by executing:
kubectl cluster-info
You should see information about the Kubernetes master and the DNS services.
Step 2: Create a Deployment Configuration File
Create a YAML file for your deployment configuration. You can name it deployment.yaml
:
nano deployment.yaml
Add the following content to define a simple Nginx deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
Step 3: Apply the Deployment
Use the following command to create the deployment on your Kubernetes cluster:
kubectl apply -f deployment.yaml
This command will create the deployment as specified in your YAML file.
Step 4: Verify the Deployment
Check the status of your deployment with:
kubectl get deployments
You should see your nginx-deployment
listed with the desired number of replicas.
Step 5: Expose the Deployment
Expose your deployment to make it accessible from outside the cluster:
kubectl expose deployment nginx-deployment --type=NodePort --port=80
Step 6: Access Your Application
To access your Nginx application, you need to find out the NodePort assigned:
kubectl get services
Note the port number and access your application at http://:
.
Step 7: Conclusion
You have successfully created your first deployment on a Kubernetes cluster. This foundational knowledge allows you to efficiently manage applications in a containerized environment. Hosting your Kubernetes cluster on a Windows VPS can enhance performance and reliability. For additional options, explore various VPS UK Windows solutions, including Windows Virtual Private Server Hosting and Windows VPS Hosting UK.