Skip to content

Commit

Permalink
feat: add hack dockefiles to regenerate code and crd manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
alias-rahil committed Mar 13, 2022
1 parent 792fcf4 commit 49ca674
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
config/
hack/
manifests/
.vscode/
.git/
.dockerignore
.gitignore
Dockerfile
README.md
kluster
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kluster
config/
.vscode
.vscode/
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


# Kluster

A example Kubernetes operator to create Kubernetes cluster on DigitalOcean.
Expand All @@ -10,7 +9,7 @@ This operator was written as part of one of my [YouTube playlist](https://www.yo

Here is an example of the Kluster resource

```
```yaml
apiVersion: viveksingh.dev/v1alpha1
kind: Kluster
metadata:
Expand All @@ -32,13 +31,13 @@ Execute below command, from root of the repo
Create Kluster CRD
```
```sh
kubectl create -f manifests/viveksingh.dev_klusters.yaml
```

Create RBAC resources and deployment

```
```sh
kubectl create -f manifests/install/
```

Expand All @@ -47,14 +46,30 @@ kubectl create -f manifests/install/
To call DigitalOcean APIs we will have to create a secret with DigitalOcean token that
will be used in the Kluster CR that we create.

```
```sh
kubectl create secret generic dosecret --from-literal token=<your-DO-token>
```

# Create a kluster CR

Create the kluster resource to create a k8s cluster in DigitalOcean

```
```sh
kubectl create -f manifests/klusterone.yaml
```

# Updating CRD manifest

Update the CRD manifest (`manifests/viveksingh.dev_klusters.yaml`) using docker:

```sh
docker buildx build --file hack/Dockerfile.update-crds -o . .
```

# Updating the auto-generated code

Update the auto-generated code (`pkg/client/` and `pkg/apis/viveksingh.dev/v1alpha1/zz_generated.deepcopy.go`) using docker:

```sh
docker buildx build --file hack/Dockerfile.update-codegen -o . .
```
14 changes: 14 additions & 0 deletions hack/Dockerfile.update-codegen
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# hack/Dockerfile.update-codegen

# Usage: docker buildx build --file hack/Dockerfile.update-codegen -o . .

FROM golang:1.13 AS build
WORKDIR /go/src/github.com/viveksinghggits/kluster
RUN go mod download k8s.io/[email protected]
COPY . .
RUN bash /go/pkg/mod/k8s.io/[email protected]/generate-groups.sh all \
github.com/viveksinghggits/kluster/pkg/client github.com/viveksinghggits/kluster/pkg/apis viveksingh.dev:v1alpha1 \
--go-header-file /go/pkg/mod/k8s.io/[email protected]/hack/boilerplate.go.txt

FROM scratch
COPY --from=build /go/src/github.com/viveksinghggits/kluster/pkg pkg
14 changes: 14 additions & 0 deletions hack/Dockerfile.update-crds
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# hack/Dockerfile.update-crds

# Usage: docker buildx build --file hack/Dockerfile.update-crds -o . .

FROM golang:1.13 AS build
WORKDIR /go/src/github.com/viveksinghggits/kluster
RUN GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected]
COPY . .
RUN controller-gen paths=github.com/viveksinghggits/kluster/pkg/apis/viveksingh.dev/v1alpha1 \
crd:crdVersions=v1 \
output:crd:artifacts:config=manifests

FROM scratch
COPY --from=build /go/src/github.com/viveksinghggits/kluster/manifests manifests

0 comments on commit 49ca674

Please sign in to comment.