Closed jkneubuh closed 2 years ago
@bjwswang does this PR enable you to run the operator locally without deploying to a container in k8s?
The env necessary to run the operator is:
export KUBECONFIG=$HOME/.kube/config
export WATCH_NAMESPACE=test-network
export CLUSTERTYPE=k8s
export OPERATOR_LOCAL_MODE=true
The PWD for the process must be the root of the git project.
Thank you very much for opening the issue and submitting a fix for the defect. This feature has been waiting for a VERY long time...
Hi @jkneubuh looking good for running locally,but how about docker mode
?
From the Dockerfile
COPY build/ /usr/local/bin
COPY definitions /definitions
COPY config/crd/bases /deploy/crds
COPY defaultconfig /defaultconfig
COPY docker-entrypoint.sh .
the operator executable file placed under /usr/local/bin
,so not sure if relative path ./definitions
still works on docker mode
.
maybe we make the base path of default configuration/template files
to be configurable.
When running in a docker container, the $PWD
for the process is /. I think the older default path prefix of ../../
was incorrect - it was resolving correctly by accident as any ancestor path of '/' will resolve to '/'. E.g.:
fuji:fabric-operator jkneubuh$ docker run -e LICENSE=accept --rm ghcr.io/hyperledger-labs/fabric-operator:latest-amd64 pwd
/
fuji:fabric-operator jkneubuh$ docker run -e LICENSE=accept --rm ghcr.io/hyperledger-labs/fabric-operator:latest-amd64 ls ./defaultconfig
ca
console
orderer
peer
fuji:fabric-operator jkneubuh$ docker run -e LICENSE=accept --rm ghcr.io/hyperledger-labs/fabric-operator:latest-amd64 ls ../../defaultconfig
ca
console
orderer
peer
fuji:fabric-operator jkneubuh$ docker run -e LICENSE=accept --rm ghcr.io/hyperledger-labs/fabric-operator:latest-amd64 ls ../../../../../../../defaultconfig
ca
console
orderer
peer
I tested this with a container / k8s and it looks OK. To test this in k8s without turning a real build through CI, I did:
make image
docker tag docker tag ghcr.io/hyperledger-labs/fabric-operator:latest-amd64 localhost:5000/fabric-operator
docker push localhost:5000/fabric-operator
export TEST_NETWORK_OPERATOR_IMAGE=localhost:5000/fabric-operator
export TEST_NETWORK_OPERATOR_IMAGE_LABEL=latest
network operator
This PR allows the operator to be launched locally without running within a Docker container / kubernetes cluster.
Fixes Issue #67
Note that this changes the default path at which the operator config files are read, from
../../
to./
. This was actually a bug / error in the original logic, as the working directory foribp-operator
in the container is actually/
. (When running from the root folder, the../../
path prefix resolves to/
on the file system.)Thank you @bjwswang for the great recommendations on pushing this forward.
Signed-off-by: Josh Kneubuhl jkneubuh@us.ibm.com