Deploy using standalone single manifest

Category : Kubernetes | Sub Category : Kubernetes With Java | By Prasad Bonam Last updated: 2023-11-21 13:27:32 Viewed : 209


Deploying using a single standalone manifest involves combining multiple Kubernetes resources (such as Deployments, Services, ConfigMaps, etc.) into a single YAML file. This approach can be convenient for managing all resources related to an application in one place. Below is an example of a single manifest file that includes a Deployment and a Service:

yaml
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 --- apiVersion: v1 kind: Service metadata: name: my-app-service spec: selector: app: my-app ports: - protocol: TCP port: 80 targetPort: 80 type: LoadBalancer

In this example:

  • The Deployment section defines the NGINX deployment with three replicas.
  • The Service section defines a LoadBalancer service for exposing the NGINX deployment.

To deploy this combined manifest:

bash
kubectl apply -f combined-manifest.yaml

This applies both the Deployment and Service to the Kubernetes cluster.

To monitor the deployment and service status:

bash
kubectl get deployments kubectl get services

To access the application:

  • If using Minikube:

    bash
    minikube service my-app-service
  • For cloud providers, wait for the external IP to be assigned to the service and access the application using that IP.

To clean up:

bash
kubectl delete -f combined-manifest.yaml

This removes both the NGINX deployment and service from the cluster.

Using a single manifest can be beneficial for simplifying deployment and management of related resources. However, as the number of resources grows, it is important to strike a balance between having a manageable manifest and modularizing for better maintainability.

Search
Related Articles

Leave a Comment: