Skip to content
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

Use templates only to deploy Che to OpenShift #9190

Merged
25 commits merged into from
Apr 17, 2018
Merged

Use templates only to deploy Che to OpenShift #9190

25 commits merged into from
Apr 17, 2018

Conversation

ghost
Copy link

@ghost ghost commented Mar 22, 2018

The purpose of this PR is to:

  1. Eventually get rid of deployment scripts to avoid deployment complexity
  2. Use OpenShift way of creating objects when user input is required

What is done

  1. OpenShift templates and other objects are introduced
  2. All env vars are parameterized and a user can provide own values
  3. Readme answers some questions and covers deployment of all Che flavors in all possible configurations.

Why not a single template?

There's no universal template that will fit all use cases. It will be easier to use upstream che-server template for those who depend on it.

Is it tested?

Yes. MiniShift and OSO. Both single and multi user. http and https

Will existing scripts go away?

Eventually, yes. But not immediately. As soon as those who depend on current deployment scripts are ready to migrate, scripts will be deleted.

Does Che deployment have all envs as parameters?

No, only those that make sense at a first glance. Further PRs are welcome.

Will these changes break CI tests?

Even though there are changes in eclipse/che-keycloak Dockerfile, a different entrypoint script is used in Keycloak deployment. So, both deployment script and templates works well, even though they use the same images.

What about Keycloak configuration pod?

Master and Che realm, as well as admin user for Keycloak and Che are created in keycloak image entrypoint.

Will docs be provided?

There's README.md to start with, but eventually docs will be updated to reference template based deployment method.

How to test?

Follow instructions in README. Use eivantsov/keycloak as Keycloak image for Keycloak deployment:

oc process -f multi/keycloak-template.yaml -p ROUTING_SUFFIX=$(minishift ip).nip.io -p IMAGE_KEYCLOAK=eivantsov/keycloak | oc apply -f -

@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Mar 22, 2018

All of the below commands create a PVC for Che server and Che deployment uses this PVC.

It is possible to avoid using PVC for Che server - just skip creating pvc `oc apply -f pvc/che-server-pvc.yaml` and `oc set volume dc/che --add -m /data --name=che-data-volume --claim-name=che-data-volume` commands.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, PVC is used by Single-User Che to store H2 Database file. Please, add a note that without PVC Single-User Che will lose all data after Pod restarting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point will do. For single user PVC is created by default - this is what I suggest in an example command.

But once again - good point.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

value: "${PROTOCOL}://che-${NAMESPACE}.${ROUTING_SUFFIX}/agent-binaries/linux_amd64/bootstrapper/bootstrapper"
- name: CHE_INFRA_KUBERNETES_MACHINE__START__TIMEOUT__MIN
value: '5'
- name: CHE_INFRA_KUBERNETES_MASTER__URL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this parameter have value? It makes sense to configure it for multi-cluster mode (When Che Server is started on one OS cluster while Workspace are created on another one)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

- name: CHE_INFRA_KUBERNETES_PVC_STRATEGY
value: "${CHE_INFRA_KUBERNETES_PVC_STRATEGY}"
- name: CHE_INFRA_KUBERNETES_PVC_PRECREATE__SUBPATHS
value: 'true'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a variable here. It makes sense to configure it. On newest OpenShift instances it may be disabled, and workspace start may speed up.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

value: '5'
- name: CHE_INFRA_KUBERNETES_MASTER__URL
- name: CHE_INFRA_KUBERNETES_OAUTH__TOKEN
value: "${TOKEN}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why OPENSHIFT_USERNAME, OPENSHIFT_PASSWORD but TOKEN? Maybe it would be better to name them in the same way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

- name: CHE_INFRA_KUBERNETES_MASTER__URL
- name: CHE_INFRA_KUBERNETES_OAUTH__TOKEN
value: "${TOKEN}"
- name: CHE_INFRA_KUBERNETES_PASSWORD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to place CHE_INFRA_KUBERNETES_PASSWORD and CHE_INFRA_KUBERNETES_USERNAME together.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

value: "${CHE_KEYCLOAK_AUTH__SERVER__URL}"
- name: CHE_JDBC_URL
value: "${CHE_JDBC_URL}"
- name: CHE_OAUTH_GITHUB_CLIENTID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can it be configured if there is no specified value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

test: false
triggers:
- type: ConfigChange
status:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that it makes sense to specify status here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

- apiVersion: v1
kind: DeploymentConfig
metadata:
creationTimestamp: null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is it removed? I still see few creationTimestamp fields in this template. Do I have an issue with browser cache?

@@ -11,3 +11,4 @@ ADD . /scripts/
USER root
RUN chgrp -R 0 /scripts && \
chmod -R g+rwX /scripts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that mandatory change? :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


## Templates and Parameters

Templates are provided with a set of predefined params which you can override with with `-p key=value`. If you miss envs and parameters, you can add them to your template.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could add which command will list parameters for a given template ?

$ oc process --parameters -f <filename>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in readme


## Creating Workspace Objects

By default, che SA is used to create workspace objects in the same namespace with Che server. This is configurable - you may provide login and password or token, and set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI sometimes Che is written che sometimes Che

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any word expected after and set ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

3. Once done, go to `https://keycloak.${NAMESPACE}.${ROUTING_SUFFIX}`, log in to admin console.
Default credentials are `admin:admin`.
Go to Clients, `che-public` client and edit **Valid Redirect URIs** and **Web Origins** URLs so that they use **https** protocol.
You do not need to do that if you initially deploy Che with https support.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like https here have spaces around

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

oc apply -f pvc/che-server-pvc.yaml; \
oc process -f che-server-template.yaml -p ROUTING_SUFFIX=$(minishift ip).nip.io \
-p PROTOCOL=https \
-p WS_PROTOCOL=wss \
Copy link
Contributor

@benoitf benoitf Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could WS_PROTOCOL/TLS be automatically computed based on the fact that it's https ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish a template can handle some ifs. I failed to find a good universal solution. Any help is appreciated.

```
oc new-project che

oc process -f che-server-template.yaml -p ROUTING_SUFFIX=$(minishift ip).nip.io | oc apply -f -; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead oc process -f <template> | oc apply -f - you could use a single command oc new-app -f <template> .... .

Besides the fact that it's a single command oc new-app has an option to add applications env vars even if these were not defined in the template: -e ENV_VAR_KEY=ENV_VAR_VALUE (c.f. oc new-app reference). That may be useful for our use cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Examples updated


Templates are provided with a set of predefined params which you can override with with `-p key=value`. If you miss envs and parameters, you can add them to your template.

IMPORTANT! **ROUTING_SUFFIX** value in the below commands `$(minishift ip).nip.io` works for MiniShift only. You MUST provide **own routing suffix** when deploying to OCP cluster.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to have a command to get this value if there is a command for that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I knew such a command :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we create a dummy service then we got the default routing suffix and then we can display/reuse it ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand. Dummy service for what?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eivantsov If I create a dummy application on openshift like nginx app and I create a service nginx and expose port 80, openshift will provide me an URL. From this URL I can guess the "routing suffix" so user has a way to find it (through a command that can try to create app, create service and route and then display the url and delete project)

It's just to have a way to provide to users "hey we can give you some hints around this routing suffix"

Copy link
Author

@ghost ghost Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lame workaround may be updating Che dc after routes for Che and Keycloak are created. This will add complexity to commands, but this way, no input is required from a user

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my approach, it was a way to see what the route could be.
in your approach, we create using defaults, grab values and update again.

in both case it would help "newcomers" so I'm fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a sub-section on How to get routing suffix.

```
oc new-project che

oc process -f che-server-template.yaml -p ROUTING_SUFFIX=$(minishift ip).nip.io | oc apply -f -; \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly oc process supports golang templates with -t option and looks like they support if clauses https://golang.org/pkg/text/template/
With this approach, we would have something similar to helm I suppose.


oc process -f che-server-template.yaml -p ROUTING_SUFFIX=$(minishift ip).nip.io | oc apply -f -; \
oc apply -f pvc/che-server-pvc.yaml; \
oc set volume dc/che --add -m /data --name=che-data-volume --claim-name=che-data-volume

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using set before applying template

Copy link
Author

@ghost ghost Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have dc/che at that point. I need to create Che deploymentConfig and then set volume for it.

The spec says oc set volumes RESOURCE/NAME --add|--remove|--list [options] so I need an object to modify, while process just produces output.


By default, che SA is used to create workspace objects in the same namespace with Che server. This is configurable - you may provide login and password or token, and set

## Upgrade from http to https

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this section somewhere in the end - more advanced stuff


## Deploy multi user Che with bundled Keycloak and Postgres (https)

```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like step with creation of the project is missing here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is not.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see it

timeoutSeconds: 60
name: che
ports:
- containerPort: 8080

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like ports are declared twice

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed

persistentVolumeClaim:
claimName: keycloak-log
test: false
status: {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?

resources:
requests:
storage: 1Gi
status: {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?

resources:
requests:
storage: 1Gi
status: {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?

persistentVolumeClaim:
claimName: postgres-data
test: false
status: {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?

targetPort: 5432
selector:
io.kompose.service: postgres
status:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?

resources:
requests:
storage: 1Gi
status: {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed?

@gorkem
Copy link
Contributor

gorkem commented Apr 12, 2018

Do we want to retire the minishift add-on eventually as well? @l0rd @eivantsov

@ghost
Copy link
Author

ghost commented Apr 12, 2018

@gorkem good question. That's two sets of yamls to maintain. Though from user's perspective, applying an addon is somewhat easier.

I tried to craft a simple CLI that deploys to MiniShift and OCP https://github.com/eivantsov/che-cli, lame code but works well, and all a user needs to do is:

oc login
oc new-project che
./eclipse-che deploy

to deploy to MiniShift. Works with OSO Pro too. I know Florent has some rust cli too.

Maybe we should look in this direction and start with an OpenShift CLI that will make it easy to deploy to any OpenShift cluster?

@l0rd
Copy link
Contributor

l0rd commented Apr 12, 2018

@gorkem that's a good point. A copy of these yaml files should be in rh-che repo too. So there will be 3 copies in 3 different repositories. Even if we retire the minishift addon we will still have the problem with rh-che. What about moving the yaml in a distinct github repository and referring to this repository? Then yaml could be versioned and published on maven central as part of the build. In this case the deployment scripts (and minishift addons) should download the yaml from the maven central as part of the deployment.

@ghost
Copy link
Author

ghost commented Apr 12, 2018

@l0rd can't rh use templates for upsteam repo?

@l0rd
Copy link
Contributor

l0rd commented Apr 12, 2018

@l0rd can't rh use templates for upsteam repo?

How? I mean we could add instructions for rh-che developers to clone upstream repo and use these yaml but that's not ideal. And the second problem is that the openshift.io CI/CD is not so flexible. Currently that's how rh-che deployment config for osio is specified.

@ghost
Copy link
Author

ghost commented Apr 12, 2018

@l0rd yes, agree.. Even now, for multi user setup a user will have to git clone Che to get all yamls. Having them versioned and packaged as tar.gz is a very good idea.

@benoitf
Copy link
Contributor

benoitf commented Apr 12, 2018

@l0rd could we just add a pom.xml on these upstream templates so that they could be published on m2 repository ?

@ghost
Copy link
Author

ghost commented Apr 12, 2018

@benoitf do you mean maven central or Che nexus?

@benoitf
Copy link
Contributor

benoitf commented Apr 12, 2018

@eivantsov if #6444 is done it should be maven central as well :-)

@garagatyi
Copy link

@benoitf 👍 Yeah, we don't really need an additional repo to publish the artifact

@l0rd
Copy link
Contributor

l0rd commented Apr 17, 2018

@eivantsov this PR looks like Penelope's shroud :-) What is missing to merge it? I am asking because I have opened a similar PR and I am waiting impatiently for this one to be merged.

@ghost
Copy link
Author

ghost commented Apr 17, 2018

@l0rd thanks for your patience and a wonderful metaphor. I have been waiting for all interested parties to have their say on templates themselves, cross platform cli that deploys to all infras and related stuff. Besides, I have introduced some changes to ocp.sh that QE uses to run daily tests, and while testing discovered a bug where PVCs were not deleted upon workspace deletion if workspace objects are created in a shared dedicated namespace (#9431) (default behavior in new templates).

Now that that QA tests show no regression , with a light heart, I merge this PR. Thanks for all suggestions and helpful remarks - they did help make templates and deployment docs better.

P.S. Old scripts and deployment yamls will stay here for a while and will be deleted in a separate PR.

Related docs PR: eclipse-che/che-docs#391

@ghost ghost merged commit fa046bd into master Apr 17, 2018
@ghost ghost deleted the templates branch April 17, 2018 11:30
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Apr 17, 2018
@benoitf benoitf added this to the 6.4.0 milestone Apr 17, 2018
@ghost ghost mentioned this pull request Apr 22, 2018
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants