Category : Kubernetes | Sub Category : Kubernetes With Java | By Prasad Bonam Last updated: 2023-11-21 10:46:33 Viewed : 512
Kubernetes is a powerful open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. Here are some key concepts in Kubernetes and an overview of how to instantiate or deploy applications in a Kubernetes cluster:
Nodes:
Pods:
ReplicaSet:
Deployment:
Service:
Namespace:
ConfigMap and Secret:
To deploy an application in Kubernetes, you typically define resources using YAML manifests and apply them to the cluster. Here is a simple example:
Create a Deployment YAML file (deployment.yaml
):
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: your-image-name:tag
ports:
- containerPort: 8080
Replace your-image-name:tag
with the actual name and tag of your Docker image.
Apply the Deployment to the Cluster:
bashkubectl apply -f deployment.yaml
This command creates the deployment, and Kubernetes ensures that three instances of your application are running.
Expose the Deployment as a Service (service.yaml
):
yamlapiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
Apply the Service to the Cluster:
bashkubectl apply -f service.yaml
This command creates a service that exposes your application to the external world.
After applying these manifests, Kubernetes will manage the deployment and scaling of your application, ensuring high availability and providing access to the service. You can monitor the status and logs of your pods using kubectl
commands.