Skip to main content

Kubernetes Deployment Explained: Spring Boot, YAML, AWS EKS & Interview Questions

Updated 25 min readMarkdown
Kubernetes Deployment Explained: Spring Boot, YAML, AWS EKS & Interview Questions

A practical end-to-end guide to Kubernetes Deployment, Service, ConfigMap, Secret Management, Ingress, Docker, CI/CD, and AWS EKS — with real-world examples and interview questions.

When working with microservices, developing an application is only one part of the job. We also need to package it, deploy it, configure it, expose APIs, manage multiple instances, and monitor its health.

This is where Kubernetes comes in.

Kubernetes helps us deploy, scale, manage, and maintain containerized applications.

But how do we actually deploy a Spring Boot application in Kubernetes?

Do we need a deployment.yaml file? What about Service, ConfigMap, Secret, and Ingress? Where should we store passwords and database credentials in production?

Let's understand the complete deployment process, from writing code to running an application in a Kubernetes cluster.

1. Kubernetes Deployment Architecture

Before writing YAML files, let's understand how different Kubernetes components work together.

Figure 1: Kubernetes Deployment Topology – Ingress, Services, Pods, ConfigMap, Secrets, and Persistent Volumes.

Let's understand the architecture:

  • Ingress Controller: Receives external HTTP/HTTPS traffic and routes it to the appropriate Service.
  • Service: Provides a stable network endpoint and distributes traffic to matching Pods.
  • Pods: Run application containers. Multiple replicas provide availability and capacity.
  • ConfigMap: Stores non-sensitive application configuration.
  • Secret: Provides sensitive configuration to applications.
  • PersistentVolume: Provides storage that can survive the lifecycle of an individual Pod.

For example, an application can have separate API, authentication, and web microservices. Each service can have its own Deployment and multiple Pods.

Important: This diagram represents the application runtime topology. The Deployment and CI/CD workflow, which creates and updates these resources, is explained later.

2. What Do We Need Before Deploying?

Before deploying an application to Kubernetes, we generally need:

  • A Spring Boot application packaged as a JAR.
  • Docker to build a container image.
  • A container registry such as AWS ECR or Docker Hub.
  • A Kubernetes cluster such as AWS EKS.
  • kubectl to communicate with the Kubernetes cluster.
  • Kubernetes YAML manifest files.

Important: Kubernetes does not directly deploy your Java source code. We first package the application into a container image, push that image to a registry, and then Kubernetes pulls and runs it.

3. Understand the Important Kubernetes YAML Files

Kubernetes uses YAML manifest files to define the desired state of resources.

For a typical Spring Boot microservice, we commonly use:

YAML file Responsibility
deployment.yaml Creates and manages application Pods
service.yaml Provides stable network access to Pods
configmap.yaml Stores non-sensitive configuration
secret.yaml Stores sensitive configuration
ingress.yaml Manages external HTTP/HTTPS access
hpa.yaml Automatically scales Pod replicas

A simple project structure:

springboot-app/
│
├── Dockerfile
├── pom.xml
│
└── kubernetes/
    ├── deployment.yaml
    ├── service.yaml
    ├── configmap.yaml
    ├── external-secret.yaml
    ├── ingress.yaml
    └── hpa.yaml

Let's understand each component.

4. Step 1: Build the Spring Boot Application

First, package your Spring Boot application into a JAR.

mvn clean package

This generates the application JAR inside the target directory.

For example:

target/app.jar

Make sure the JAR filename matches the one used in your Dockerfile.

5. Step 2: Create a Docker Image

Create a file named Dockerfile in your project root.

FROM eclipse-temurin:17-jre

WORKDIR /app

COPY target/app.jar app.jar

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "app.jar"]

Build the Docker image:

docker build -t springboot-app:1.0 .

Now we have a Docker image containing our Spring Boot application.

Next, we push this image to a container registry such as AWS Elastic Container Registry (ECR) or Docker Hub.

Kubernetes will use this image to start application containers.

Production tip: Use versioned or immutable image tags rather than repeatedly overwriting the latest tag.

6. Step 3: Deployment.yaml – Manage Application Pods

A Deployment tells Kubernetes how to create and maintain application Pods.

For example, if we want to run three instances of our Spring Boot application, we configure three replicas.

Example deployment.yaml:

apiVersion: apps/v1
kind: Deployment

metadata:
  name: springboot-app

spec:
  replicas: 3

  selector:
    matchLabels:
      app: springboot

  template:
    metadata:
      labels:
        app: springboot

    spec:
      containers:
        - name: springboot-container
          image: your-registry/springboot-app:1.0
          imagePullPolicy: IfNotPresent

          ports:
            - containerPort: 8080

          envFrom:
            - configMapRef:
                name: springboot-config
            - secretRef:
                name: database-secret

          startupProbe:
            httpGet:
              path: /actuator/health/liveness
              port: 8080
            periodSeconds: 10
            failureThreshold: 30

          readinessProbe:
            httpGet:
              path: /actuator/health/readiness
              port: 8080
            periodSeconds: 10

          livenessProbe:
            httpGet:
              path: /actuator/health/liveness
              port: 8080
            periodSeconds: 15

          resources:
            requests:
              cpu: "250m"
              memory: "256Mi"
            limits:
              cpu: "500m"
              memory: "512Mi"

Important configurations:

  • replicas: 3 – Runs three Pod replicas.
  • image – Specifies the container image.
  • imagePullPolicy – Controls when Kubernetes pulls the image.
  • containerPort – Application container port.
  • labels – Identifies the Pods.
  • selector – Helps the Deployment identify the Pods it manages.
  • startupProbe – Checks whether application startup has completed.
  • readinessProbe – Checks whether a Pod is ready to receive traffic.
  • livenessProbe – Checks whether a container is healthy and should continue running.
  • resources – Defines CPU and memory requests and limits.

What does Deployment provide?

  • Creates and manages Pods.
  • Maintains the desired number of replicas.
  • Recreates Pods when they fail.
  • Supports rolling updates and rollbacks.

Important: These health endpoints require Spring Boot Actuator and appropriate health probe configuration. For example:

management.endpoint.health.probes.enabled=true

7. Step 4: Service.yaml – Expose Your Application

Pods are temporary. Their IP addresses can change when they are recreated.

How can other microservices reliably communicate with them?

Kubernetes Service solves this problem.

Example service.yaml:

apiVersion: v1
kind: Service

metadata:
  name: springboot-service

spec:
  type: ClusterIP

  selector:
    app: springboot

  ports:
    - port: 80
      targetPort: 8080

Important configurations:

  • type: ClusterIP – Exposes the application inside the cluster.
  • port: 80 – Service port.
  • targetPort: 8080 – Application container port.
  • selector – Routes traffic to Pods with the matching label.

Remember: Deployment manages Pods, whereas Service provides a stable network endpoint to access them.

8. Step 5: ConfigMap.yaml – Externalize Application Configuration

In real-world applications, we should avoid hardcoding environment-specific configurations inside our application image.

For example:

  • Active Spring profile.
  • Application port.
  • Feature flags.
  • External service URLs.
  • Database connection URL.

We can use ConfigMap.

Example configmap.yaml:

apiVersion: v1
kind: ConfigMap

metadata:
  name: springboot-config

data:
  SPRING_PROFILES_ACTIVE: "prod"
  SERVER_PORT: "8080"
  SPRING_DATASOURCE_URL: "jdbc:postgresql://db-host:5432/appdb"

We reference this ConfigMap inside Deployment using:

envFrom:
  - configMapRef:
      name: springboot-config

This allows us to change configuration without rebuilding the Docker image.

9. Step 6: Secret Management – Where Should We Store Passwords and Credentials?

This is one of the most important topics in real-world application deployment.

Imagine we have a Spring Boot application that connects to PostgreSQL.

We need:

  • Database username.
  • Database password.
  • API keys.
  • Third-party service credentials.
  • JWT signing keys.

Should we store these values inside secret.yaml and push the file to GitHub?

No. Never commit actual passwords, API keys, or credentials to Git.

Even Kubernetes Secret YAML files are not automatically safe for source control. Kubernetes Secrets are commonly represented using Base64 encoding, which is not encryption.

So where should we store them?

For applications running on AWS EKS, AWS Secrets Manager is a good option for centrally managing sensitive information.

Example:

AWS Secrets Manager
        |
        | Stores credentials securely
        |
        v
EKS IAM Permissions
        |
        v
Kubernetes Secret Integration
        |
        v
Spring Boot Application

For example, create a secret in AWS Secrets Manager:

Secret name:
prod/springboot/database

Secret value:
{
  "username": "admin",
  "password": "your-secure-password"
}

The actual credentials remain in AWS Secrets Manager, not in your Git repository.

How Does Kubernetes Fetch Secrets at Runtime?

There are two common approaches.

Approach A: External Secrets Operator

External Secrets Operator (ESO) integrates external secret providers such as AWS Secrets Manager with Kubernetes.

The flow is:

  1. Store credentials in AWS Secrets Manager.
  2. Configure an AWS IAM role for the External Secrets Operator using EKS Pod Identity or IRSA.
  3. Configure an External Secrets ClusterSecretStore or SecretStore.
  4. Create an ExternalSecret resource referencing the AWS secret.
  5. ESO retrieves the secret and creates a Kubernetes Secret.
  6. The application Deployment references that Kubernetes Secret.

Example external-secret.yaml:

apiVersion: external-secrets.io/v1
kind: ExternalSecret

metadata:
  name: springboot-database-secret

spec:
  refreshInterval: 1h

  secretStoreRef:
    name: aws-secrets-manager
    kind: ClusterSecretStore

  target:
    name: database-secret
    creationPolicy: Owner

  data:
    - secretKey: SPRING_DATASOURCE_USERNAME
      remoteRef:
        key: prod/springboot/database
        property: username

    - secretKey: SPRING_DATASOURCE_PASSWORD
      remoteRef:
        key: prod/springboot/database
        property: password

Here:

  • secretStoreRef identifies the configured external secret provider.
  • remoteRef.key identifies the secret in AWS Secrets Manager.
  • property identifies the value inside the stored JSON.
  • secretKey defines the key created in the Kubernetes Secret.
  • refreshInterval controls how frequently ESO checks for changes.

Important: The ClusterSecretStore must already be configured with appropriate AWS permissions. The External Secrets Operator and its CRDs must also be installed in the cluster.

The ExternalSecret manifest contains references to credentials, not the actual passwords.

How Does Spring Boot Get These Credentials?

Once ESO creates the Kubernetes Secret, our Deployment can reference it.

envFrom:
  - secretRef:
      name: database-secret

Kubernetes makes these values available as environment variables inside the application container.

Spring Boot automatically recognizes:

SPRING_DATASOURCE_USERNAME
SPRING_DATASOURCE_PASSWORD

And uses them to configure the datasource.

The complete flow:

AWS Secrets Manager
        |
        v
External Secrets Operator
        |
        v
Kubernetes Secret
        |
        v
Spring Boot Deployment
        |
        v
Environment Variables
        |
        v
Spring Boot Datasource
        |
        v
PostgreSQL Database

What happens when the password changes?

ESO can periodically refresh the Kubernetes Secret from AWS Secrets Manager.

However, environment variables inside an already running container do not automatically change when the Kubernetes Secret is updated.

You may need to restart the Pods to load the updated environment variables. Alternatively, use a supported mounted-secret approach or retrieve secrets directly from the external provider at runtime.

Approach B: AWS Secrets Manager with Secrets Store CSI Driver

Another approach is using the Secrets Store CSI Driver with the AWS provider.

Instead of copying secrets into a Kubernetes Secret, the driver can mount secrets as files inside the application Pod.

The application can read the mounted secret files at runtime.

Example flow:

AWS Secrets Manager
        |
        v
Secrets Store CSI Driver
        |
        v
Mounted Secret Files
        |
        v
Spring Boot Application

This approach is useful when applications are designed to read credentials from files.

Which Approach Should We Choose?

Approach How the application gets secrets Common use
Kubernetes Secret Environment variables or mounted files Basic Kubernetes integration
External Secrets Operator Syncs external secrets into Kubernetes Secrets AWS Secrets Manager integration
Secrets Store CSI Driver Mounts external secrets as files File-based secret access
AWS SDK Application retrieves secrets directly Runtime secret retrieval

My recommendation for AWS EKS: Use AWS Secrets Manager with External Secrets Operator or the Secrets Store CSI Driver, depending on your application requirements.

Use IAM roles and least-privilege permissions. Avoid storing actual credentials in Git, Docker images, or plain-text deployment manifests.

10. Step 7: Ingress.yaml – Expose APIs Outside the Cluster

A Service with ClusterIP is accessible only inside the Kubernetes cluster.

What if external users need to access our application using a URL?

We can use Ingress with an appropriate Ingress Controller.

Example ingress.yaml:

apiVersion: networking.k8s.io/v1
kind: Ingress

metadata:
  name: springboot-ingress

spec:
  ingressClassName: nginx

  rules:
    - host: api.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: springboot-service
                port:
                  number: 80

Ingress routes HTTP/HTTPS requests to the Kubernetes Service.

For example:

https://api.example.com
        |
        v
Ingress Controller
        |
        v
springboot-service
        |
        v
Spring Boot Pods

Note: Creating an Ingress resource alone is not enough. An Ingress Controller, such as NGINX Ingress Controller or an AWS-supported ingress solution, must be installed and configured to process the rules.

11. Step 8: HPA – Automatically Scale Your Application

What happens when application traffic increases?

Instead of manually increasing the number of Pods, Kubernetes provides Horizontal Pod Autoscaler (HPA).

Example hpa.yaml:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler

metadata:
  name: springboot-hpa

spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: springboot-app

  minReplicas: 2
  maxReplicas: 10

  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70

Here:

  • minReplicas: 2 – Minimum number of Pods.
  • maxReplicas: 10 – Maximum number of Pods.
  • averageUtilization: 70 – Target average CPU utilization.

HPA automatically adjusts the number of replicas based on configured metrics.

Important: CPU-based HPA requires metrics infrastructure, commonly Metrics Server, and CPU resource requests must be defined for the containers.

When HPA manages a Deployment, avoid repeatedly overriding its replica count through manual updates or deployment manifests.

12. Step 9: Deploy the Application Using kubectl

Once all the YAML files are ready, we can deploy the application to Kubernetes.

First, make sure your Kubernetes context points to the correct cluster and namespace.

Apply configuration resources:

kubectl apply -f kubernetes/configmap.yaml

If using External Secrets Operator:

kubectl apply -f kubernetes/external-secret.yaml

Wait for the external secret to be synchronized:

kubectl get externalsecrets
kubectl get secrets

Then deploy the application:

kubectl apply -f kubernetes/deployment.yaml

kubectl apply -f kubernetes/service.yaml

kubectl apply -f kubernetes/ingress.yaml

kubectl apply -f kubernetes/hpa.yaml

You can also apply the complete directory:

kubectl apply -f kubernetes/

Referenced resources such as ConfigMaps and Secrets must exist before application Pods can start successfully.

Verify the Deployment

Check the Deployment:

kubectl get deployments

Check Pods:

kubectl get pods

Check Services:

kubectl get services

Check Ingress:

kubectl get ingress

Check application logs:

kubectl logs <pod-name>

Check Deployment details:

kubectl describe deployment springboot-app

Wait for the rollout to complete:

kubectl rollout status deployment/springboot-app

13. Complete End-to-End Deployment Flow

Now let's connect everything.

In a real-world microservices project, developers generally don't manually build and deploy every application. We use a CI/CD pipeline to automate the process.

Let's understand the complete workflow using Jenkins or GitHub Actions and AWS EKS.

Step 1: Developer Writes Code

A developer creates or updates a Spring Boot microservice and pushes changes to GitHub, GitLab, or Bitbucket.

Step 2: CI/CD Pipeline Starts

A CI/CD pipeline is triggered.

Common tools include:

  • Jenkins
  • GitHub Actions
  • GitLab CI/CD

The pipeline performs compilation, unit testing, and code quality checks.

Step 3: Package the Application

mvn clean package

This generates the Spring Boot JAR file.

Step 4: Build Docker Image

docker build -t springboot-app:1.0 .

The pipeline uses the Dockerfile to package the JAR into a Docker image.

Step 5: Push Image to Container Registry

The Docker image is pushed to AWS ECR or another container registry.

docker push <registry>/springboot-app:1.0

Step 6: Deploy to Kubernetes

The CI/CD pipeline connects to the Kubernetes cluster and applies the YAML manifests.

kubectl apply -f kubernetes/

For AWS EKS, the pipeline needs appropriate AWS credentials, EKS access, and Kubernetes permissions.

The worker nodes also need appropriate permissions to pull images from ECR.

Step 7: Kubernetes Creates Pods

The Deployment controller ensures the desired number of Pods are running.

For example, if replicas: 3, Kubernetes tries to maintain three application Pods.

Step 8: Service Routes Traffic

The Service selects matching Pods and provides a stable endpoint for communication between microservices.

Step 9: Ingress Exposes the Application

The Ingress Controller routes external HTTP/HTTPS traffic to the Service.

Step 10: Monitor the Application

After deployment, we monitor application health, logs, resource usage, and availability.

Common tools include:

  • Prometheus
  • Grafana
  • AWS CloudWatch
  • Splunk
  • Kubernetes health probes

Complete Deployment Architecture

                 DEVELOPER
                     |
                     v
          GitHub / GitLab / Bitbucket
                     |
                     v
                CI/CD PIPELINE
             Jenkins / GitHub Actions
                     |
                     v
               Build and Test
                Spring Boot JAR
                     |
                     v
                 Docker Build
                     |
                     v
              Docker Container Image
                     |
                     v
               AWS ECR / Registry
                     |
                     v
              AWS EKS CLUSTER
                     |
                     v
           Kubernetes Deployment
                     |
                     v
               Application Pods
              (Spring Boot Containers)
                     |
                     v
             Kubernetes Service
                (ClusterIP)
                     |
                     v
              Ingress Controller
                     |
                     v
             External Users / APIs
                     |
                     v
            Monitoring and Logging

What Happens When We Release a New Version?

Suppose we are upgrading our application from version 1.0 to 2.0.

  1. Developer pushes the latest code.
  2. CI/CD pipeline builds and tests the application.
  3. A new Docker image is created and pushed to the registry.
  4. The Deployment image is updated to version 2.0.
  5. Kubernetes performs a rolling update according to the Deployment strategy.
  6. New Pods become ready, and old Pods are gradually replaced.

Example:

kubectl set image deployment/springboot-app \
  springboot-container=your-registry/springboot-app:2.0

Check the rollout:

kubectl rollout status deployment/springboot-app

If something goes wrong, we can roll back:

kubectl rollout undo deployment/springboot-app

This helps us release new versions without necessarily stopping the entire application.

14. Deployment vs Service – Quick Comparison

Feature Deployment Service
Purpose Manages Pods Provides stable networking
Creates Pods Yes No
Scaling Yes No
Self-healing Maintains desired replicas No
Rolling updates Yes No
Stable network endpoint No Yes

15. Important Kubernetes Resources – Quick Revision

Resource Responsibility
Deployment Creates and manages Pods
Pod Runs one or more containers
Service Provides stable networking
ConfigMap Stores non-sensitive configuration
Secret Stores sensitive configuration
Ingress Manages external HTTP/HTTPS routing
HPA Automatically scales Pod replicas
PVC Requests persistent storage
Namespace Logically separates resources

16. Kubernetes Interview Questions – Beginner to Experienced

Here are 38 practical Kubernetes interview questions covering fundamentals, Docker, deployment, networking, scaling, troubleshooting, and AWS EKS.

Basic Kubernetes Questions

1. What is Kubernetes, and why do we need it?

Kubernetes is a container orchestration platform that automates application deployment, scaling, networking, and container management.

2. What is the difference between Docker and Kubernetes?

Docker and Kubernetes serve different purposes in containerized application development.

  • Docker: Used to build, package, and run applications inside containers.
  • Kubernetes: Used to manage, deploy, scale, and orchestrate containers across multiple machines.

Example:

Imagine we have a Spring Boot microservice.

  1. Docker packages the Spring Boot application into a container image.
  2. Kubernetes deploys that image and manages multiple running instances (Pods).
  3. Kubernetes handles scaling, networking, self-healing, and rolling updates.
Feature Docker Kubernetes
Main purpose Containerization Container orchestration
Builds images Yes No
Runs containers Yes Through container runtimes
Scaling Mostly manual or external tools Automated using HPA
Self-healing Container restart policies Maintains desired Pod state
Networking Docker networking Kubernetes networking and Services
Rolling updates Not a built-in orchestration feature Supported through Deployments

Interview one-liner: Docker packages and runs applications in containers, whereas Kubernetes manages and orchestrates those containers across a cluster.

Remember: Docker and Kubernetes are not competitors. They solve different problems and are commonly used together.

3. What is a Pod?

A Pod is the smallest deployable unit in Kubernetes. It can contain one or more containers that share networking and storage resources.

4. What is the difference between a Pod and a Deployment?

A Pod runs containers, whereas a Deployment manages Pods, maintains replicas, and supports rolling updates and rollbacks.

5. What is the difference between Deployment and StatefulSet?

Deployment is generally used for stateless applications. StatefulSet is designed for applications requiring stable identities and persistent storage, such as databases.

6. What is a Namespace?

A Namespace logically separates resources inside a Kubernetes cluster. It is useful for separating development, testing, and production environments.

Networking and Service Questions

7. What are the different types of Kubernetes Services?

  • ClusterIP – Internal cluster communication.
  • NodePort – Exposes an application through a port on each Node.
  • LoadBalancer – Exposes an application using an external load balancer.
  • ExternalName – Maps a Service to an external DNS name.

8. How do two microservices communicate inside Kubernetes?

They generally communicate using Kubernetes Service DNS names.

For example:

http://order-service:8080

9. What happens if a Pod IP changes?

The Service provides a stable endpoint and routes traffic to matching endpoints.

10. What is the difference between Ingress and LoadBalancer Service?

A LoadBalancer Service exposes a service through an external load balancer. Ingress provides HTTP/HTTPS routing rules, commonly allowing multiple applications to share an entry point.

11. What is the role of an Ingress Controller?

It implements Ingress rules and routes incoming HTTP/HTTPS traffic to the appropriate Kubernetes Services.

Deployment and Scaling Questions

12. What is a rolling update?

A rolling update gradually replaces old Pods with new Pods during an application deployment.

13. How do you roll back a failed deployment?

Use:

kubectl rollout undo deployment/springboot-app

14. What is HPA in Kubernetes?

Horizontal Pod Autoscaler automatically increases or decreases the number of Pod replicas based on configured metrics such as CPU or memory utilization.

15. What is the difference between HPA and VPA?

  • HPA adjusts the number of Pod replicas.
  • VPA adjusts container resource requests and limits based on observed usage.

16. What are resource requests and limits?

Requests define the resources Kubernetes uses when scheduling a Pod. Limits define the maximum resources a container can consume.

17. What is the difference between readiness, liveness, and startup probes?

  • Readiness – Determines whether a Pod should receive traffic.
  • Liveness – Determines whether a container should be restarted.
  • Startup – Determines whether an application has completed startup.

Real-Time Troubleshooting Questions

18. Your Pod is showing CrashLoopBackOff. How would you troubleshoot it?

First, check the Pod status and logs:

kubectl get pods

kubectl logs <pod-name>

kubectl describe pod <pod-name>

Check for application startup errors, incorrect environment variables, missing configuration, failed health checks, and resource issues.

19. Your Pod is showing ImagePullBackOff. What could be the reason?

Possible reasons:

  • Incorrect Docker image name or tag.
  • Image does not exist in the registry.
  • Missing registry authentication.
  • Kubernetes node cannot access the container registry.

Check:

kubectl describe pod <pod-name>

20. Your Pod is stuck in Pending state. What could be the reason?

Possible reasons:

  • Insufficient CPU or memory on worker nodes.
  • Incorrect resource requests.
  • Persistent volume not available.
  • Node selector or scheduling constraints.

Check:

kubectl describe pod <pod-name>
kubectl get nodes

21. Your application is running, but the Service is not routing traffic. What would you check?

Check whether Service selectors match Pod labels.

kubectl get pods --show-labels

kubectl describe service springboot-service

kubectl get endpoints springboot-service

Also check Pod readiness and the Service's target port.

22. What happens when a container exceeds its memory limit?

The container may be terminated with an OOMKilled status. Kubernetes may restart it depending on the Pod's restart policy.

23. Your application is deployed successfully, but users are getting HTTP 503. How would you investigate?

Check:

  • Pod readiness status.
  • Service selectors and endpoints.
  • Ingress configuration.
  • Ingress Controller logs.
  • Application health and port configuration.

24. How do you check application logs in Kubernetes?

kubectl logs <pod-name>

For a specific container:

kubectl logs <pod-name> -c <container-name>

For previous container logs after a restart:

kubectl logs <pod-name> --previous

Advanced and AWS EKS Questions

25. How does Kubernetes perform self-healing?

Controllers continuously compare the actual cluster state with the desired state and take corrective action. For example, a Deployment creates replacement Pods when replicas are missing.

26. How does Kubernetes pull Docker images from AWS ECR?

The Kubernetes worker nodes need appropriate AWS permissions to authenticate and pull images from ECR. In EKS, this is commonly configured through the worker node IAM role or the relevant node identity mechanism.

27. How do you deploy a Spring Boot application on AWS EKS?

A typical process:

  1. Package the Spring Boot application.
  2. Build a Docker image.
  3. Push the image to AWS ECR.
  4. Configure access to the EKS cluster.
  5. Apply Kubernetes YAML manifests.
  6. Verify Pods, Services, and Ingress.
  7. Monitor application health and logs.

28. How does CI/CD work with Kubernetes?

A CI/CD pipeline such as Jenkins or GitHub Actions builds and tests the application, creates a Docker image, pushes it to a registry, and deploys the updated Kubernetes manifests.

29. What is the difference between ConfigMap and Secret?

ConfigMap stores non-sensitive configuration, whereas Secret is intended for sensitive information such as passwords and API keys.

30. How do you manage secrets in production on AWS EKS?

You can integrate Kubernetes with AWS Secrets Manager using External Secrets Operator or the Secrets Store CSI Driver. Use IAM roles and least-privilege permissions to control access.

31. What is the difference between Kubernetes Deployment and Docker Compose?

Docker Compose is commonly used to define and run multi-container applications, especially in local development. Kubernetes provides cluster-level orchestration, scheduling, scaling, service discovery, and self-healing.

Practical Scenario-Based Questions

32. You have three Spring Boot microservices. How would you expose them using Kubernetes?

Create a separate Deployment and Service for each microservice. Use Ingress or a suitable gateway to route external requests to the required Services.

33. Your application works locally but fails after deployment to Kubernetes. What would you check?

Check environment-specific configurations, database connectivity, container image, environment variables, Secrets, network policies, resource limits, and application logs.

34. How would you deploy a new version without downtime?

Use a Deployment with a rolling update strategy, appropriate readiness probes, sufficient replicas, and correct availability settings. Verify the rollout before considering the deployment complete.

35. How would you troubleshoot high CPU usage in a Pod?

Check resource usage:

kubectl top pods

kubectl describe pod <pod-name>

Then investigate application performance, CPU limits, traffic volume, and thread or processing bottlenecks.

36. How do you scale an application during high traffic?

You can increase replicas manually or configure HPA to automatically scale based on CPU, memory, or supported custom metrics.

37. Where should we store database passwords and API keys in an AWS EKS environment?

Use AWS Secrets Manager or another approved secrets-management solution. Integrate it with Kubernetes using External Secrets Operator or the Secrets Store CSI Driver, with appropriate IAM permissions.

38. What is the difference between IRSA and EKS Pod Identity?

Both provide a way for Kubernetes workloads to obtain AWS IAM permissions without storing long-lived AWS credentials inside application containers.

  • IRSA: Uses IAM roles associated with Kubernetes service accounts.
  • EKS Pod Identity: Uses an EKS-managed association between Kubernetes service accounts and IAM roles.

Quick Interview Revision

Concept Remember
Docker Builds and runs containers
Kubernetes Orchestrates containers
Pod Runs containers
Deployment Manages Pods
Service Stable networking
ConfigMap Non-sensitive configuration
Secret Sensitive configuration
Ingress HTTP/HTTPS routing
HPA Scales Pod replicas
PVC Persistent storage request
Namespace Logical resource separation
Readiness Probe Controls traffic eligibility
Liveness Probe Detects unhealthy containers
Startup Probe Protects slow application startup

Interview preparation tip: Don't just memorize Kubernetes definitions. Practice troubleshooting Pods, Services, Deployments, image-pulling failures, health checks, secret management, and application connectivity. These practical scenarios help demonstrate real-world Kubernetes knowledge.

Conclusion

Kubernetes makes application deployment, scaling, and management easier through declarative YAML configurations.

For a typical Spring Boot microservice, the important resources to understand are:

  • Deployment
  • Service
  • ConfigMap
  • Secret
  • Ingress
  • HPA

In real-world projects, these components work together with Docker, container registries, CI/CD pipelines, and Kubernetes clusters such as AWS EKS.

Remember this simple flow:

Developer Code → CI/CD → Docker Image → Container Registry → Kubernetes Deployment → Pods → Service → Ingress → Users.

And for production secrets:

AWS Secrets Manager → Kubernetes Secret Integration → Spring Boot Application.

Once you understand these complete workflows, deploying Spring Boot microservices on Kubernetes becomes much easier.

Happy Learning! 🚀

💬 Feedback?

Found this useful?
Leave a comment or connect with me on LinkedIn.

#Kubernetes #Docker #SpringBoot #Microservices #AWS #DevOps #Java

About the author

  • 👨‍💻 I'm Praveen Gupta, a Senior Backend Engineer with over 10+ years of experience in designing scalable backend systems using Java, Spring Boot, Microservices, and AWS Cloud. I specialize in building cloud-native applications, integrating DevOps practices, and mentoring teams in writing clean, production-grade code. I created this blog to share real-world backend architecture tips, Spring Boot patterns, and practical coding solutions that help developers grow faster.

No comments yet. Be the first to comment.