1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

[Feature] Enhance devcontainer (#7175)

* added minikube and docker support

Signed-off-by: Ved Ratan <vedratan8@gmail.com>

* added docs

Signed-off-by: Ved Ratan <vedratan8@gmail.com>

---------

Signed-off-by: Ved Ratan <vedratan8@gmail.com>
Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Ved Ratan 2023-06-06 21:47:23 +05:30 committed by GitHub
parent 248e6be073
commit c4e7c5f854
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 15 deletions

View file

@ -1,11 +1,32 @@
FROM golang:1.20
RUN apt update && apt install -y sudo git
FROM ubuntu:latest
RUN apt-get update && apt-get install -y sudo git curl apt-transport-https ca-certificates gnupg-agent software-properties-common
ARG USERNAME=root
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
ENV DEVCONTAINER=true
# Install Golang
RUN curl -LO https://dl.google.com/go/go1.20.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf go1.20.linux-amd64.tar.gz \
&& rm go1.20.linux-amd64.tar.gz \
&& echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
COPY . .
# Install Docker
# Install Docker
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
RUN echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io
# Install kubectl and Minikube
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \
&& chmod +x kubectl && mv kubectl /usr/local/bin/ \
&& curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& install minikube-linux-amd64 /usr/local/bin/minikube \
&& minikube config set driver docker
# Expose ports for Minikube and Docker
EXPOSE 22 80 2375 8443
CMD ["/bin/bash"]

View file

@ -4,5 +4,7 @@
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "root"
"remoteUser": "root",
"mounts": ["source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"],
"runArgs": ["--privileged", "--network=host", "-p", "22:22", "-p", "80:80", "-p", "2375:2375", "-p", "8443:8443"]
}

View file

@ -32,16 +32,15 @@ It contains instructions to build, run, and test Kyverno.
- Clone the project to your local machine.
- Make sure that you have the Visual Studio Code editor installed on your system.
- Make sure that you have the Docker installed on your system.
- Make sure that you have wsl(Ubuntu preferred) and Docker installed on your system and on wsl too (docker.sock (UNIX socket) file is necessary to enable devcontainer to communicate with docker running in host machine).
- Open the project in Visual Studio Code.
- Open the project in Visual Studio Code, once the project is opened hit F1 and type wsl, now click on "Reopen in WSL".
- If you haven't already done so, install the **Dev Containers** extension in Visual Studio Code.
- Once the extension is installed, you should see a green icon in the bottom left corner of the window.
- After you have installed Dev Containers extension, it should automatically detect the .devcontainer folder inside the project,
and should suggest you to open the project in container.
- After you have installed Dev Containers extension, it should automatically detect the .devcontainer folder inside the project opened in wsl, and should suggest you to open the project in container.
- If it doesn't suggest you, then press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>p</kbd> and search "reopen in container" and click on it.