-
Notifications
You must be signed in to change notification settings - Fork 1
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
[WIP] console-operator based on client-go #2
Open
benjaminapetersen
wants to merge
24
commits into
enj:master
Choose a base branch
from
benjaminapetersen:console-operator-refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
432ab80
Renamed all occurance of "example" to "console". Regenerate pkg/gener…
benjaminapetersen 4053c8f
Update manifests to match existing console-operator manifests
benjaminapetersen 0211c3f
Update Dockerfile & create Dockerfile.osx for local
benjaminapetersen dde0e00
Adding back examples/config.yaml as this will likely be needed
benjaminapetersen a1dd54d
Update README to include expected flags & build/run process
benjaminapetersen 030787e
Add `console version` command
benjaminapetersen e49a054
Add some dev_*.sh scripts
benjaminapetersen 1012bf3
Update README
benjaminapetersen 848530d
Add dev_delete_all.sh hack script
benjaminapetersen b778e5d
Comment on dev_run_local.sh
benjaminapetersen c3eb95c
Add todo to version command
benjaminapetersen 45e1fb3
Add comment to cmd/operator/cmd.go
benjaminapetersen ab8a721
Update dev_run_local.sh (f)
benjaminapetersen 51e05a1
Create ClusterOperatorStatus in starter.go
benjaminapetersen 1c0cbc7
Add all clients, informers to starter, operator
benjaminapetersen 4b93caf
Create default console if CR does not exist
benjaminapetersen 563299b
Update sync loop, add Apply for all subresources
benjaminapetersen ff8d7e4
Add dev_* scripts for convenience
benjaminapetersen 584f8ad
Add TODO to types.go to describe future custom host work
benjaminapetersen efb8e65
Update sync loop, tmp remove OwnerRef
benjaminapetersen 4b3f802
Return to functioning reconcile loop
benjaminapetersen d4a81c9
Handle ManagementState: Removed, refactor 'Default' resource function…
benjaminapetersen e1d6052
Clean up excessive comments
benjaminapetersen d59d60c
f
benjaminapetersen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
# This is an example operator. | ||
# | ||
# The standard name for its image is enj/example-operator | ||
# | ||
FROM openshift/origin-release:golang-1.10 | ||
COPY . /go/src/github.com/enj/example-operator | ||
RUN cd /go/src/github.com/enj/example-operator && go build ./cmd/example | ||
FROM openshift/origin-release:golang-1.10 as builder | ||
WORKDIR /go/src/github.com/openshift/console-operator | ||
COPY . . | ||
RUN make build | ||
|
||
FROM centos:7 | ||
COPY --from=0 /go/src/github.com/enj/example-operator/example /usr/bin/example | ||
RUN useradd console-operator | ||
USER console-operator | ||
COPY --from=builder /go/src/github.com/openshift/console-operator/_output/local/bin/linux/amd64/console /usr/bin | ||
|
||
# these manifests are necessary for the installer | ||
COPY manifests /manifests/ | ||
|
||
LABEL io.k8s.display-name="OpenShift console-operator" \ | ||
io.k8s.description="This is a component of OpenShift Container Platform and manages the lifecycle of the web console." \ | ||
io.openshift.tags="openshift" \ | ||
maintainer="Benjamin A. Petersen <bpetersen@redhat.com>" | ||
|
||
LABEL io.openshift.release.operator true | ||
|
||
# entrypoint specified in 03-operator.yaml as `console-operator` | ||
# CMD ["/usr/bin/console", "operator", "--kubeconfig", "path/to/config", "--config", "./install/config.yaml", "--v", "4"] | ||
CMD ["/usr/bin/console", "operator", "--v", "4"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM openshift/origin-release:golang-1.10 as builder | ||
WORKDIR /go/src/github.com/openshift/console-operator | ||
COPY . . | ||
RUN make build | ||
|
||
FROM centos:7 | ||
RUN useradd console-operator | ||
USER console-operator | ||
COPY --from=builder /go/src/github.com/openshift/console-operator/_output/local/bin/darwin/amd64/console /usr/bin | ||
|
||
# these manifests are necessary for the installer | ||
COPY manifests /manifests/ | ||
|
||
LABEL io.k8s.display-name="OpenShift console-operator" \ | ||
io.k8s.description="This is a component of OpenShift Container Platform and manages the lifecycle of the web console." \ | ||
io.openshift.tags="openshift" \ | ||
maintainer="Benjamin A. Petersen <bpetersen@redhat.com>" | ||
|
||
LABEL io.openshift.release.operator true | ||
|
||
# entrypoint specified in 03-operator.yaml as `console-operator` | ||
# CMD ["/usr/bin/console", "operator", "--kubeconfig", "path/to/config", "--config", "./install/config.yaml", "--v", "4"] | ||
CMD ["/usr/bin/console", "operator", "--v", "4"] | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,84 @@ | ||
# Example Operator | ||
# Console Operator | ||
|
||
```shell | ||
cd "${GOPATH}/src/github.com/enj/example-operator" | ||
An operator for OpenShift Console built using the operator-sdk. | ||
|
||
oc new-project example-operator | ||
The console-operator installs and maintains the web console on a cluster. | ||
|
||
oc create -f manifests/00-crd.yaml | ||
oc create -f install/cr.yaml | ||
## Run on a 4.0.0 cluster | ||
|
||
The console operator is installed by default and will automatically maintain a console. | ||
|
||
## Development Setup | ||
|
||
* Install Go -- https://golang.org/doc/install | ||
|
||
## Development on a < 4.0.0 cluster | ||
|
||
If using `oc cluster up` on a `< 4.0.0` cluster you will need the `--public-hostname` flag | ||
when you cluster up. The `--server-loglevel` flag is helpful for debugging. OAuth issues | ||
will not be visible unless set to at least `3`. | ||
|
||
```bash | ||
# there are a variety of ways to get your machine IP address | ||
# this example works on OSX | ||
oc cluster up --public-hostname=$(ipconfig getifaddr en0) --server-loglevel 3 | ||
``` | ||
|
||
Then, create the manifests: | ||
|
||
```bash | ||
# pre 4.0.0 needs this, but it is not part of the post 4.0.0 manifests payload | ||
oc create -f ./examples/crd-clusteroperator.yaml | ||
# standard 4.0.0 deploy of the operator | ||
oc create -f ./manifests | ||
# to run the operator locally, delete the deployment and follow instructions below | ||
oc delete -f ./manifests/05-operator.yaml | ||
``` | ||
|
||
If you don't know where your `kubeconfig` file is: | ||
|
||
```bash | ||
# just a high number | ||
oc whoami --loglevel=100 | ||
# likely output will be $HOME/.kube/config | ||
``` | ||
|
||
Build the console operator binary: | ||
|
||
```bash | ||
make update-codegen | ||
make | ||
export PATH="_output/local/bin/linux/amd64:${PATH}" | ||
example operator --kubeconfig admin.kubeconfig --config install/config.yaml --v=4 | ||
make verify | ||
# add the binary to your path | ||
# arc will be "linux" or "darwin", etc | ||
export PATH="_output/local/bin/<arc>/amd64:${PATH}" | ||
``` | ||
|
||
Now, run the console operator locally: | ||
|
||
```bash | ||
IMAGE=docker.io/openshift/origin-console:latest \ | ||
console operator \ | ||
--kubeconfig $HOME/.kube/config \ | ||
--config examples/config.yaml \ | ||
--create-default-console \ | ||
--v 4 | ||
``` | ||
|
||
oc get exampleoperator example-operator-resource -o yaml | ||
oc get secret example-operator-resource -o yaml | ||
Check for the existence of expected resources: | ||
|
||
```bash | ||
oc get console | ||
# etc | ||
``` | ||
|
||
|
||
Explanation: | ||
|
||
- The `IMAGE` env var is needed to declare what console image to deploy. The `manifests/05-operator.yaml` shows this var as well | ||
- The `--operator-flags` flag is used to pass flags to the operator binary | ||
- `--create-default-console true` tells the operator binary to create a console CR if one does not exist on startup. | ||
|
||
The `IMAGE` env var exists so that when the console-operator is packaged up for a release, we can replace the value | ||
with a final image. See CVO documentation for details. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
# this just deletes everything under /manifests, | ||
# but tries to space them out a bit to avoid errors. | ||
# in the end, it creates a custom resource to kick | ||
# the operator into action | ||
|
||
FILE=examples/cr.yaml | ||
echo "creating ${FILE}" | ||
oc create -f $FILE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quick copy paste, haven't tested that one yet. |
||
|
||
for FILE in `find ./manifests -name '05-*'` | ||
do | ||
echo "deleting ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
for FILE in `find ./manifests -name '04-*'` | ||
do | ||
echo "deleting ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
for FILE in `find ./manifests -name '03-*'` | ||
do | ||
echo "deleting ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
for FILE in `find ./manifests -name '02-*'` | ||
do | ||
echo "deleting ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
for FILE in `find ./manifests -name '01-*'` | ||
do | ||
echo "deleting ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
for FILE in `find ./manifests -name '00-*'` | ||
do | ||
echo "deleting ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
# this just deploys everything under /manifests, | ||
# but tries to space them out a bit to avoid errors. | ||
# in the end, it creates a custom resource to kick | ||
# the operator into action | ||
|
||
for FILE in `find ./manifests -name '00-*'` | ||
do | ||
echo "creating ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
sleep 2 | ||
|
||
for FILE in `find ./manifests -name '01-*'` | ||
do | ||
echo "creating ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
sleep 2 | ||
|
||
for FILE in `find ./manifests -name '02-*'` | ||
do | ||
echo "creating ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
sleep 2 | ||
|
||
for FILE in `find ./manifests -name '03-*'` | ||
do | ||
echo "creating ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
sleep 2 | ||
|
||
for FILE in `find ./manifests -name '04-*'` | ||
do | ||
echo "creating ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
sleep 2 | ||
|
||
for FILE in `find ./manifests -name '05-*'` | ||
do | ||
echo "creating ${FILE}" | ||
oc create -f $FILE | ||
done | ||
|
||
sleep 2 | ||
|
||
|
||
FILE=examples/cr.yaml | ||
echo "creating ${FILE}" | ||
oc create -f $FILE |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?