Add an Entry Point Command to Kubernetes Deployment

An entry point specifies what arguments a Docker or Kubernetes should pass to the container when it launches it. The entry point can be a command in the container file or an absolute or relative path to a binary on your system.

A while ago, we covered how to add an entry point to a Docker container, and today we will cover how to do it with a Kubernetes deployment object.

In the manifest file below (YAML), I have a deployment object that is an entry point to run a specific command when the pod is deployed. I’m using the below example because I don’t want the pod to turn ideal and terminated.

The two lines below make the entry point for the container \ pod. The command defines the shell to run the commands that are in the args.

command: ["/bin/sh"]
args: ["-c", "sleep infinity"]

You can see the entire deployment file below.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: server-deployment
spec:
  selector:
    matchLabels:
      app: server-app
  template:
    metadata:
      labels:
        app: server-app
    spec:
      containers:
        - name: server-app
          image: ubuntu
          command: ["/bin/sh"]
          args: ["-c", "sleep infinity"]
      restartPolicy: Always  
         

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.