Kubernetes Deep Dive

Sign Up Free or Log In to participate!

how do you do apt-get updates or other installs to a k8 pod as it is created – is there a list of pod creation rules?

as above

3 Answers

I presume one would do this using a CMD layer within the container image. When you create a pod from this image the CMD layer will be executed. Just an educated guess as this is not something I have experience of

containers should be immutable, simply pro

Running the install commands after deployment would be inefficient. What you would do is create a Dockerfile, build the image, upload the image (Dockerhub is free), and then swap the image in the YAML file for the one you’ve built.

Dockerfile

======

FROM ubuntu:latest

RUN  apt-get update -y && apt-get install curl

=====

Those are the only two lines you need

docker image build -t dockerhub_username/container_name:tag_name .

docker push dockerhub_username/container_name:tag_name

Build with command above, the period indicates the dockerfile is in your current directory, push it to docker hub, then your image is available to use! Just reference the image name: "dockerhub_username/container_name:tag_name"

Hope this helps!

Peter O’Neill

But I guess if you wanted the quick and dirty method, you could also just add it in before the sleep command.

Peter O’Neill

command: – /bin/bash – "-c" – "apt-get update -y && apt-get install curl && sleep 60m"

Peter O’Neill

It seems I can’t enter new line characters, but each – should start on a new line.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?