Skip to content

Instantly share code, notes, and snippets.

@dyennam
Created April 7, 2020 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dyennam/9fabc8f35929f9ca3de9c79ee3d54d31 to your computer and use it in GitHub Desktop.
Save dyennam/9fabc8f35929f9ca3de9c79ee3d54d31 to your computer and use it in GitHub Desktop.
Dockerfile for octact UI
FROM debian:stretch-slim as octant-build
WORKDIR /
RUN DEBIAN_FRONTEND=noninteractive; \
apt-get update && \
apt-get install \
--auto-remove \
--no-install-recommends \
--no-install-suggests \
--show-upgraded \
--yes \
ca-certificates \
curl
ARG OCTANT_VERSION=0.11.1
RUN curl -L -O "https://github.com/vmware-tanzu/octant/releases/download/v${OCTANT_VERSION}/octant_${OCTANT_VERSION}_Linux-64bit.tar.gz" \
&& tar -xzf octant_${OCTANT_VERSION}_Linux-64bit.tar.gz \
&& cp octant_${OCTANT_VERSION}_Linux-64bit/octant /octant
# FROM scratch as octant
FROM centos:centos7 as octant
WORKDIR /tmp
COPY k8configs/kubeconfig-k8s.yaml /usr/local/bin
# Checking if the file copied correctly
RUN cd /usr/local/bin && \
ls -la &&\
pwd
COPY --from=octant-build /octant /octant
EXPOSE 7777
ENTRYPOINT [ "/octant", "--disable-open-browser", "--listener-addr", "0.0.0.0:7777", "--kubeconfig=/usr/local/bin/kubeconfig.k8s.yaml","--namespace=apicentral", "-v"]
@dsiebel
Copy link

dsiebel commented Apr 8, 2020

... continuation of the discussion in vmware-archive/octant#507

A couple of things I noticed:

  1. The --kubeconfig option does not seem to work, or at least it doesn't work how I would expect it to do. I fixed it by having the kubeconfig in the default path for the user running the container (root): /root/.kube/config/
  2. no idea why scratch isn't working for you. Does the build not work or just running octant in it?
  3. nitpick: /usr/local/bin is a directory for binaries/executables, configuration should reside either in the home directory of the user or in /usr/local/etc/ or /etc/

@dyennam
Copy link
Author

dyennam commented Apr 8, 2020

  1. it worked for me, but was very intermittent. As in sometimes when i open the octant URL, it shows me the pods in my default Namespace. But other times, it wont even load. I will Change it to root instead of ../bin and give it a shot.
  2. The build works, but it was never able to pick up the KUBECFG file at runtime. Issue could be, i was trying to place the KUBECFG in a directory which doesn't exist in scratch.
  3. I agree, will change it to something more sane. :)
    Appreciate the feedback.

@dsiebel
Copy link

dsiebel commented Apr 9, 2020

The problem with the --kubeconfig flag in your Dockerfile is the =. The line should read:

ENTRYPOINT [ "/octant", "--disable-open-browser", "--listener-addr", "0.0.0.0:7777", "--kubeconfig", "/usr/local/bin/kubeconfig.k8s.yaml","--namespace", "apicentral", "-v"]

The fun with golang cli arguments 🙄 ...

For me that works. However, switching contexts does not. The Problem here is that I am running macOS and the kubeconfig contains an absolute path to the auth provider for that kubernetes context. My cluster is located in Google Kubernetes Engine so it tries to run the google-cloud-sdk which does not exist in the linux container obviously. And if it does it wouldn't be located at /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/gcloud. No solution for that one, yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment