Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Set up development environment with Skaffold #393

Merged
merged 6 commits into from
Nov 15, 2023

Conversation

knqyf263
Copy link
Collaborator

@knqyf263 knqyf263 commented Oct 28, 2023

Description

This PR has made several updates to streamline the setup of the development environment using Skaffold, aligning with modern Kubernetes practices. The following are the major changes:

  1. Updated Go Version Requirement:

    • The project now requires Go version 1.21 (required by log/slog) or later, updated from Go version 1.17.
  2. Revised development instructions:

    • Replaced Docker Compose with Skaffold for a more streamlined and Kubernetes-native workflow.
    • Changed the development environment setup from Vagrant to Kubernetes.
    • Added New Dockerfile for Development**:
    • Introduced a new Dockerfile.dev to cater to the development environment setup with Skaffold
  3. Submodule Addition:

    • Added a submodule for harbor-helm to manage Helm chart dependencies for Harbor
    • Need to use the local chart as remoteChart in Skaffold seems to have a bug.

Signed-off-by: knqyf263 <[email protected]>
Signed-off-by: knqyf263 <[email protected]>
@knqyf263 knqyf263 marked this pull request as ready for review October 28, 2023 07:02
Signed-off-by: knqyf263 <[email protected]>
Signed-off-by: knqyf263 <[email protected]>
@chen-keinan
Copy link
Contributor

chen-keinan commented Oct 29, 2023

@knqyf263 look like very cool framework.

I have followed instruction and got this error following to make dev

WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /Users/chen.keinan/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /Users/chen.keinan/.kube/config
Error: uninstall: Release not loaded: my-harbor: release: not found
Cleaning up resources encountered an error, will continue to clean up other resources.
loading images into kind nodes: invalid reference format

any idea ?

@knqyf263
Copy link
Collaborator Author

@chen-keinan Are you using kind? I guess it also showed a more detailed error than invalid reference format. Can you please share error messages?

@chen-keinan
Copy link
Contributor

@chen-keinan Are you using kind? I guess it also showed a more detailed error than invalid reference format. Can you please share error messages?

yes using kind.

this is the full output , I do not see additional error data:

☁  harbor-scanner-trivy [pr-393] make dev
skaffold dev --tolerate-failures-until-deadline=true
Generating tags...
 - aquasecurity/harbor-scanner-trivy -> aquasecurity/harbor-scanner-trivy:v0.30.17-6-gdb3f8fb
Checking cache...
 - aquasecurity/harbor-scanner-trivy: Not found. Building
Starting build...
Found [kind-harbor-scanner-trivy] context, using local docker daemon.
Building [aquasecurity/harbor-scanner-trivy]...
Target platforms: [linux/arm64]
#0 building with "default" instance using docker-container driver

#1 [internal] load build definition from Dockerfile.dev
#1 transferring dockerfile: 1.09kB done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/library/golang:1.21-alpine
#2 ...

#3 [auth] library/golang:pull token for registry-1.docker.io
#3 DONE 0.0s

#4 [auth] aquasec/trivy:pull token for registry-1.docker.io
#4 DONE 0.0s

#5 [internal] load metadata for docker.io/aquasec/trivy:0.46.0
#5 DONE 1.2s

#2 [internal] load metadata for docker.io/library/golang:1.21-alpine
#2 DONE 1.3s

#6 [internal] load .dockerignore
#6 transferring context: 2B done
#6 DONE 0.0s

#7 [builder 1/7] FROM docker.io/library/golang:1.21-alpine@sha256:926f7f7e1ab8509b4e91d5ec6d5916ebb45155b0c8920291ba9f361d65385806
#7 resolve docker.io/library/golang:1.21-alpine@sha256:926f7f7e1ab8509b4e91d5ec6d5916ebb45155b0c8920291ba9f361d65385806 done
#7 DONE 0.0s

#8 [stage-1 1/3] FROM docker.io/aquasec/trivy:0.46.0@sha256:03f63713c91ee7576391738e6ff6ef79683419285f019d8a1b4174f2708f5a46
#8 resolve docker.io/aquasec/trivy:0.46.0@sha256:03f63713c91ee7576391738e6ff6ef79683419285f019d8a1b4174f2708f5a46 done
#8 DONE 0.0s

#9 [internal] load build context
#9 transferring context: 2.12kB done
#9 DONE 0.0s

#10 [builder 6/7] COPY pkg/ ./pkg
#10 CACHED

#11 [builder 5/7] COPY cmd/ ./cmd
#11 CACHED

#12 [builder 3/7] COPY go.mod go.sum ./
#12 CACHED

#13 [stage-1 2/3] RUN adduser -u 10000 -D -g '' scanner scanner
#13 CACHED

#14 [builder 4/7] RUN go mod download
#14 CACHED

#15 [builder 2/7] WORKDIR /go/src/github.com/aquasecurity/harbor-scanner-trivy
#15 CACHED

#16 [builder 7/7] RUN CGO_ENABLED=0 go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o scanner-trivy cmd/scanner-trivy/main.go
#16 CACHED

#17 [stage-1 3/3] COPY --from=builder /go/src/github.com/aquasecurity/harbor-scanner-trivy/scanner-trivy /home/scanner/bin/scanner-trivy
#17 CACHED
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Build [aquasecurity/harbor-scanner-trivy] succeeded
Tags used in deployment:
 - aquasecurity/harbor-scanner-trivy ->
Starting deploy...
Loading images into kind cluster nodes...
 -  -> Cleaning up...
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /Users/chen.keinan/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /Users/chen.keinan/.kube/config
Error: uninstall: Release not loaded: my-harbor: release: not found
Cleaning up resources encountered an error, will continue to clean up other resources.
loading images into kind nodes: invalid reference format
make: *** [dev] Error 1

@knqyf263
Copy link
Collaborator Author

knqyf263 commented Oct 30, 2023

In my environment, the image is exported at the end.

#16 exporting to image
#16 exporting layers 0.0s done
#16 writing image sha256:97cb896fa18cd3e7466927735112c64a03a33a3c9aae821981a6f7ed9882b503 done
#16 naming to docker.io/aquasecurity/harbor-scanner-trivy:v0.30.18-6-g5255848-dirty done
#16 DONE 0.0s

Your output shows a warning about exporting. The built image is not used for some reason.

WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load

Are you using Docker Desktop on macOS or something else?

@chen-keinan
Copy link
Contributor

In my environment, the image is exported at the end.

#16 exporting to image
#16 exporting layers 0.0s done
#16 writing image sha256:97cb896fa18cd3e7466927735112c64a03a33a3c9aae821981a6f7ed9882b503 done
#16 naming to docker.io/aquasecurity/harbor-scanner-trivy:v0.30.18-6-g5255848-dirty done
#16 DONE 0.0s

Your output shows a warning about exporting. The built image is not used for some reason.

WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load

Are you using Docker Desktop on macOS or something else?

Using Podman

@knqyf263
Copy link
Collaborator Author

Looks like Skaffold doesn't support Podman.
GoogleContainerTools/skaffold#8430

@knqyf263
Copy link
Collaborator Author

@chen-keinan I've updated the document.
1edd712

Can you please try with Docker? Skaffold is really convenient for local development. I strongly want to use it 😄

@chen-keinan
Copy link
Contributor

@chen-keinan I've updated the document. 1edd712

Can you please try with Docker? Skaffold is really convenient for local development. I strongly want to use it 😄

still unable to make it work, but I can look at it later

@chen-keinan chen-keinan merged commit a7b601e into aquasecurity:main Nov 15, 2023
2 checks passed
@knqyf263 knqyf263 deleted the local_dev branch November 16, 2023 00:47
@knqyf263
Copy link
Collaborator Author

still unable to make it work, but I can look at it later

OK, I'm here to help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants