kubernetesbusybox

Is it possible to install curl into busybox in kubernetes pod


I am using busybox to detect my network problem in kubernetes v1.18 pods. I created the busybox like this:

apiVersion: v1
kind: Pod
metadata:
    name: busybox
    namespace: default
spec:
    containers:
    - name: busybox
    image: busybox:1.28
    command:
        - sleep
        - "3600"
    imagePullPolicy: IfNotPresent
    restartPolicy: Always

and login to find the kubernetes clusters network situation:

 kubectl exec -it busybox /bin/bash

What surprises me is that the busybox does not contain curl. Why does the busybox package not include the curl command? I am searching the internet and find the docs do not talk about how to add curl into busybox. I tried to install curl, but found no way to do this. Is there anyway to add curl package into busybox?


Solution

  • The short answer, is you cannot.

    Why?

    Because busybox does not have package manager like: yum, apk, or apt-get ..

    Acutally you have two solutions:

    1. Either use a modified busybox

    You can use other busybox images like progrium/busybox which provides opkg-install as a package manager.

    image: progrium/busybox
    

    Then:

    kubectl exec -it busybox -- opkg-install curl
    

    2. Or if your concern to use a minimal image, you can use alpine

    image: alpine:3.12
    

    then:

    kubectl exec -it alpine -- apk --update add curl