Deploying a Tomcat Application on Kubernetes with Deployment and Service YAML
This guide explains the relationship between Pods and controllers, introduces Kubernetes Deployments for managing stateless applications, and provides a complete YAML example to create a Tomcat Deployment with three replicas and a NodePort Service, followed by the kubectl command to apply the configuration.
Pods and controllers in Kubernetes are linked via label selectors; controllers manage Pods for operations such as scaling and rolling updates.
A Deployment manages stateless applications, handling Pods and ReplicaSets, providing declarative updates, scaling, and rollback capabilities.
The following example creates a Deployment for a Tomcat container with three replicas and a corresponding Service of type NodePort to expose port 80.
apiVersion: apps/v1beta1
kind: Deployment
metadata:
labels:
app: tomcat
name: tomcat
spec:
replicas: 3
selector:
matchLabels:
app: tomcat
template:
metadata:
labels:
app: tomcat
spec:
imagePullSecrets:
- name: registry-pull-secret
containers:
- image: tomcat
imagePullPolicy: Always
name: tomcat
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: tomcat-service
labels:
app: tomcat
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
selector:
app: tomcatApply the configuration with kubectl apply -f tomcat-deployment.yaml to create the Deployment and Service in the cluster.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
