Deploy using standalone manifests

Category : Kubernetes | Sub Category : Kubernetes With Java | By Prasad Bonam Last updated: 2023-11-21 10:58:31 Viewed : 203

Deploying using standalone manifests involves creating separate YAML files for different Kubernetes resources (such as Deployments, Services, ConfigMaps, etc.) and applying these manifests to a Kubernetes cluster using kubectl. Below is a step-by-step guide to deploying a simple application using standalone manifests:

1. Create Deployment Manifest:

Create a file named deployment.yaml with the following content:

apiVersion: apps/v1 kind: Deployment metadata: name: my-app-deployment spec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-app-container image: nginx:latest ports: - containerPort: 80

This Deployment manifest defines a simple NGINX deployment with three replicas.

2. Create Service Manifest:

Create a file named service.yaml with the following content:

apiVersion: v1 kind: Service metadata: name: my-app-service spec: selector: app: my-app ports: - protocol: TCP port: 80 targetPort: 80 type: LoadBalancer

This Service manifest defines a LoadBalancer service for exposing the NGINX deployment.

3. Apply Manifests to the Cluster:

Run the following commands to apply the deployment and service manifests to the Kubernetes cluster:

kubectl apply -f deployment.yaml kubectl apply -f service.yaml

This deploys the NGINX application and exposes it through the LoadBalancer service.

4. Monitor Deployment Status:

You can monitor the status of the deployment using the following command:

kubectl get deployments

This should show information about your my-app-deployment with the desired and current replicas.

5. Monitor Service Status:

You can check the status of the service using:

kubectl get services

This should show information about your my-app-service including the external IP if you are using a cloud provider.

6. Access the Application:

If using Minikube, you can access the service using:

minikube service my-app-service

For cloud providers, you might need to wait for the external IP to be assigned to the service and then access the application using that IP.

7. Clean Up:

To delete the deployed resources, use the following commands:

kubectl delete deployment my-app-deployment kubectl delete service my-app-service

This removes the NGINX deployment and service from the cluster.

Deploying using standalone manifests is a common practice in Kubernetes and allows you to manage your applications resources in a modular and version-controlled way. As your application grows, you can create additional manifests for other resources such as ConfigMaps, Secrets, PersistentVolumes, etc.

Related Articles

Leave a Comment: