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:
yamlapiVersion: 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:
To deploy this combined manifest:
bashkubectl apply -f combined-manifest.yaml
This applies both the Deployment and Service to the Kubernetes cluster.
To monitor the deployment and service status:
bashkubectl get deployments kubectl get services
To access the application:
If using Minikube:
bashminikube 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:
bashkubectl 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.