aerospike / aerospike-kubernetes-operator

Kubernetes operator for the Aerospike database
https://docs.aerospike.com/cloud/kubernetes/operator
Apache License 2.0
92 stars 37 forks source link

Cannot build aerospike operator #35

Closed jfwm2 closed 3 years ago

jfwm2 commented 3 years ago

Hello

By internal security policy we are required to use approved base images for our containers; therefore we must build the aerospike operator.

Unfortunately, we are having issues building it; besides the obvious "go build" (see below) we also tried to modify/regenerate module dependencies, as well as, using several versions of operator-sdk but it did not work :(.

Could you please give us some pointers?

Thanks Jean-Francois Weber-Marx jf.webermarx@criteo.com

$ github git clone git@github.com:aerospike/aerospike-kubernetes-operator.git
Cloning into 'aerospike-kubernetes-operator'...
remote: Enumerating objects: 1758, done.
remote: Counting objects: 100% (880/880), done.
remote: Compressing objects: 100% (510/510), done.
remote: Total 1758 (delta 512), reused 643 (delta 336), pack-reused 878
Receiving objects: 100% (1758/1758), 15.89 MiB | 2.42 MiB/s, done.
Resolving deltas: 100% (1053/1053), done.

$ cd aerospike-kubernetes-operator 

$ go build .
go: github.com/operator-framework/operator-sdk@v0.12.1-0.20191113210304-dc4b52186933 requires
    github.com/operator-framework/operator-registry@v1.1.1 requires
    bitbucket.org/ww/goautoneg@v0.0.0-20120707110453-75cd24fc2f2c: reading https://api.bitbucket.org/2.0/repositories/ww/goautoneg?fields=scm: 404 Not Found
arrowplum commented 3 years ago

@sud82 I believe you have more complete build instructions to add to the documentation. Could you add it to this ticket please?

sud82 commented 3 years ago

Hi @jfwm2, You have to use the operator-sdk build command to build the operator. Please try the given commands and let me know if you face any issues.

operator-sdk build --image-build-args '--build-arg OPERATOR_VERSION=\<anyversion>' \<operator-docker-path> docker push \<operator-docker-path>

e.g. operator-sdk build --image-build-args '--build-arg OPERATOR_VERSION=v0.0.1' aerospike/aerospike-kubernetes-operator:v0.0.1 docker push aerospike/aerospike-kubernetes-operator:v0.0.1

jfwm2 commented 3 years ago

Thanks for your answer @sud82!

I tried the command you provided (using operator-sdk v0.19.4, since the build command is deprecated afterwards) and I got the result below. Basically the underlying "go build" command issued by the operator-sdk fails as previously.

root@3084d7f58070:/aerospike-kubernetes-operator# operator-sdk-v0.19.4-x86_64-linux-gnu build --image-build-args '--build-arg OPERATOR_VERSION=v0.0.1' aerospike/aerospike-kubernetes-operator:v0.0.1
[Deprecation Notice] Operator SDK has a new CLI and project layout that is aligned with Kubebuilder.
See `operator-sdk init -h` and the following doc on how to scaffold a new project:
https://v0-19-x.sdk.operatorframework.io/docs/golang/quickstart/
To migrate existing projects to the new layout see:
https://sdk.operatorframework.io/docs/building-operators/golang/project_migration_guide/

go: github.com/operator-framework/operator-sdk@v0.12.1-0.20191113210304-dc4b52186933 requires
    github.com/operator-framework/operator-registry@v1.1.1 requires
    bitbucket.org/ww/goautoneg@v0.0.0-20120707110453-75cd24fc2f2c: reading https://api.bitbucket.org/2.0/repositories/ww/goautoneg?fields=scm: 404 Not Found
FATA[0000] Failed to build operator binary: failed to exec []string{"go", "build", "-o", "/aerospike-kubernetes-operator/build/_output/bin/aerospike-kubernetes-operator", "-gcflags", "all=-trimpath=/", "-asmflags", "all=-trimpath=/", "github.com/aerospike/aerospike-kubernetes-operator/cmd/manager"}: exit status 1

If you would like to reproduce, I used the latest ubuntu image for this test. I wonder how you proceed for releases. Do you have a go.mod file different from the one on the repository?

Thanks Jean-Francois

sud82 commented 3 years ago

Hi @jfwm2, bitbucket.org/ww/goautoneg is a 3rd party dependency, which has been deleted by its owner. We have it locally and that's how we build it before release. We can check if we can share that dependency with you based on its license. Another option can be that you wait for the operator-sdk upgrade, which will be coming in the next three to four weeks.

jfwm2 commented 3 years ago

Hello @sud82, that would be great if you could provide the missing dependency! Also, maybe you could use vendoring (on a separate branch if not master) so we could have a consistent set of dependency.

arrowplum commented 3 years ago

@sud82 https://github.com/adjust/goautoneg does this work as a replacement?

jfwm2 commented 3 years ago

Thanks @arrowplum!! It works for me :)

$ go mod edit -replace bitbucket.org/ww/goautoneg=github.com/adjust/goautoneg@d788f35a0315672bc90f50a6145d1252a230ee0d && go mod download
$ go build -o build/_output/bin/aerospike-kubernetes-operator github.com/aerospike/aerospike-kubernetes-operator/cmd/manager
$ ls -l build/_output/bin/aerospike-kubernetes-operator
-rwxr-xr-x  1 jf.webermarx  1945998319  43714688 May 27 06:34 build/_output/bin/aerospike-kubernetes-operator
arrowplum commented 3 years ago

@jfwm2 thank you for verifying and providing the pull request! Please close once that gets merged @sud82

arrowplum commented 3 years ago

Closing since pull request is merged. Thanks again @jfwm2