Cloud Native 2 min read

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.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Deploying a Tomcat Application on Kubernetes with Deployment and Service YAML

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: tomcat

Apply the configuration with kubectl apply -f tomcat-deployment.yaml to create the Deployment and Service in the cluster.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeDeploymentYAMLServiceTomcat
Practical DevOps Architecture
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.