Hi, I’m new to Kubernetes and I don’t understand what’s going on. I need some help, please.
I created an image from Ubuntu 22.04 with the installation of some packages:
# Use the base image of Ubuntu 22.04
FROM ubuntu:22.04
# Set the working directory
WORKDIR /app
# Update and install basic dependencies
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
curl \
bash \
python3 \
python3-pip \
python3-dev \
build-essential \
iputils-ping \
iproute2 \
net-tools \
iputils-tracepath \
&& rm -rf /var/lib/apt/lists/*
# Install ipython and ipyparallel via pip
RUN pip3 install ipython ipyparallel
# Check if python3, pip3, ipython, and ipyparallel were installed correctly
RUN python3 --version && pip3 --version && ipython --version && pip show ipyparallel
# Expose the port for the iPython controller
EXPOSE 8888
# Default command to run bash
CMD ["tail", "-f", "/dev/null"]
When I create a Docker container and access or ask the container for its IP on eth0
, it gives it to me perfectly. But when I create a Kubernetes container (Pod) with the same image, the network-related packages are not installed, and therefore, I cannot access the container’s IP.
Can anyone tell me what I’m doing wrong? Why does the Docker container have all the packages installed correctly, but the Kubernetes container (Pod) does not?
The YAML for the Kubernetes container is as follows:
apiVersion: v1
kind: Pod
metadata:
name: ipfe-pod
namespace: default
spec:
containers:
- name: ipfe
image: faasioflex/ipython:jogugil
command: ["tail"]
args: ["-f", "/dev/null"]
tolerations:
- key: "node.kubernetes.io/not-ready"
operator: "Exists"
effect: "NoExecute"
- key: "node.kubernetes.io/unreachable"
operator: "Exists"
effect: "NoExecute"
And the test steps are:
jogugil@PHOSKI:~/mydocker/mydocker/ipython/kubernetes$ docker run --rm -it faasioflex/ipython:jogugil bash
root@22ac28a9d044:/app# ip -f inet -br addr show dev eth0
eth0@if98 UP 172.17.0.2/16
root@22ac28a9d044:/app# exit
exit
jogugil@PHOSKI:~/mydocker/mydocker/ipython/kubernetes$ kubectl apply -f ej23-00.yaml
pod/ipfe-pod created
jogugil@PHOSKI:~/mydocker/mydocker/ipython/kubernetes$ kubectl get pods
NAME READY STATUS RESTARTS AGE
apache-pod 1/1 Running 6 22h
ipfe-pod 1/1 Running 0 8s
nginx-pod 1/1 Running 6 22h
jogugil@PHOSKI:~/mydocker/mydocker/ipython/kubernetes$ kubectl exec -it ipfe-pod -- bash
root@ipfe-pod:/app# ip -f inet -br addr show dev eth0
bash: ip: command not found
root@ipfe-pod:/app#