Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker development environment #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ examples/*.srl
.vscode
.gitpod.yml
cmd/machine-controller/__debug_bin
.env
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@ COPY --from=builder \
/go/src/github.com/kubermatic/machine-controller/webhook \
/usr/local/bin/
USER nobody

FROM docker.io/golang:${GO_VERSION} AS dev

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

WORKDIR /src

COPY go.mod ./
COPY go.sum ./
RUN go mod download

ENV GOCACHE=/src/.buildcache

VOLUME [ "/src" ]

ENTRYPOINT [ "/entrypoint.sh" ]

CMD [ "/usr/local/go/bin/go", "run", "./cmd/machine-controller/main.go", "-kubeconfig=.kubeconfig", "-logtostderr", "-v=6", "-metrics-address=0.0.0.0:8080", "-health-probe-address=0.0.0.0:8085", "-node-csr-approver", "-node-container-runtime=containerd" ]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@ data:

## Development

### Docker

1. Copy the `kubeconfig.yml` file of your cluster into the working directory
```
cp </path/to/your/kubeconfig.yml> .kubeconfig
```

1. Create a `.env` file
```
touch .env
```

1. Add needed environment variables to the `.env` file e.g.:
```
API_TOKEN_FOR_CLOUD_PROVIDER=super-secret-api-key
```

1. Start the development container with `docker-compose`
```
docker-compose up
```

### Testing

#### Unittests
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
machine-controller:
build:
context: .
target: dev
volumes:
- ./:/src
env_file:
- .env
ports:
- 8080:8080
16 changes: 16 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

if [[ ! -f "machine-controller" ]]; then
echo "Building userdata"
make build-machine-controller
fi

if [[ ! -f ".kubeconfig" ]]; then
echo "Unable to find $(pwd)/.kubeconfig"
echo "Make sure to put your .kubeconfig file into the root directory of the project"
exit 1
fi

exec "$@"