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

Add reference implementation example #138

Merged
merged 8 commits into from
Feb 19, 2024

Conversation

nabuskey
Copy link
Collaborator

@nabuskey nabuskey commented Jan 26, 2024

Adds an example for the cnoe ref implementation. Related to #142

Signed-off-by: Manabu Mccloskey <[email protected]>
@nabuskey nabuskey changed the title WIP: reference implementation Add reference implementation example Feb 7, 2024
@nabuskey nabuskey marked this pull request as ready for review February 7, 2024 16:28
@cmoulliard
Copy link
Contributor

Question: As the goal of this project = idpbuilder is to help the developers when they create/design an IDP platform, will the backstage app installed with the example include the needed "plugins" able to show the following views: argocd, keycloak, etc ?

@cmoulliard
Copy link
Contributor

Can you please link the issue #142 to this PR's description ?


This example creates a local version of the CNOE reference implementation.

## Installation
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add a prerequisite section as I suspect that we need:

  • kubectl installed + kube OIDC login plugin (?),
  • idpbuilder version 0.x (the x should be defined ;-))
  • An account on Amazon and S3 bucket,

Copy link
Contributor

Choose a reason for hiding this comment

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

also do we need something to put in there with regards to system specs? or at least memory requirements. my 16G core i7 cant handle it well.

@cmoulliard
Copy link
Contributor

Can we please add also cert manager ?

@nabuskey
Copy link
Collaborator Author

nabuskey commented Feb 8, 2024

Question: As the goal of this project = idpbuilder is to help the developers when they create/design an IDP platform, will the backstage app installed with the example include the needed "plugins" able to show the following views: argocd, keycloak, etc ?

Yeah plugins are baked in with the image. Source is available here: https://github.com/cnoe-io/backstage-app

Can you please link the issue #142 to this PR's description ?

I mentioned it in the description but this issue is a bit different so I won't close the issue.

Can we please add also cert manager?

I left it out because it's heavy as-is, in terms of resource utilization.

Signed-off-by: Manabu McCloskey <[email protected]>
@nimakaviani nimakaviani requested review from cmoulliard and nimakaviani and removed request for cmoulliard February 9, 2024 19:09
Copy link
Contributor

@nimakaviani nimakaviani left a comment

Choose a reason for hiding this comment

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

looks great. some minor comments from me

examples/ref-implementation/README.md Outdated Show resolved Hide resolved

This example creates a local version of the CNOE reference implementation.

## Installation
Copy link
Contributor

Choose a reason for hiding this comment

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

also do we need something to put in there with regards to system specs? or at least memory requirements. my 16G core i7 cant handle it well.

3. **Crossplane**, AWS providers, and basic compositions for deploying cloud related resources (needs your credentials for this to work)
4. **External Secrets** to generate secrets and coordinate secrets between applications.
5. **Keycloak** as the identity provider for applications.
6. **Spark Operator** to demonstrate an example Spark workload through Backstage.
Copy link
Contributor

Choose a reason for hiding this comment

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

if someone doesnt want Spark for example, is it as easy as removing the manifests for it? or is there extra configuration in other components that they need to tweak?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

also do we need something to put in there with regards to system specs? or at least memory requirements. my 16G core i7 cant handle it well.

That's actually concerning. On my Ubuntu machine it consumes about 5GB memory. How much resources are you allocating to Docker Desktop VM?

if someone doesnt want Spark for example, is it as easy as removing the manifests for it? or is there extra configuration in other components that they need to tweak?

yea just need to remove the argocd app spec

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you use Apache Spark as example ? AFAIK, there is no backstage plugin, so what could be the added value to propose it as example ?
Remark: Should we instead propose as example a microservice such as Spring Boot, Quarkus, Nodejs or combination ?

examples/ref-implementation/README.md Show resolved Hide resolved

![img.png](images/demo2-entity.png)

Deployment processes are the same as the first example. Instead of deploying a pod, we deployed a workflow to create a Spark job.
Copy link
Contributor

Choose a reason for hiding this comment

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

can we link to the location in the git repo where this workflow can be found

examples/ref-implementation/README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,35 @@
{%- if values.awsResources %}
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about splitting the example applications into a separate folder, so we have one folder for a vanilla reference implementation, and another to deploy the example apps. doing something like the following in the readme:

idpbuilder create --package-dir examples/ref-implementation --package-dir examples/sample-apps

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would rather just have one command to deploy everything.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that we should dissociate the process to install the reference implementation (= components A + B + C etc) from the step to install an example top of the reference platform. Why ? As the goal of the tool is to provision a cluster, than such implementation should be used for different purposes, to allow the users to deploy also their own examples, or examples defined in a lab project, etc

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah +1 on what Charles said above.

Comment on lines +296 to +304
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X PUT --data @/tmp/user-password-to-be-applied.json \
http://keycloak.keycloak.svc.cluster.local:8080/admin/realms/cnoe/users/${USER1ID}/reset-password

curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X PUT --data @/tmp/user-password-to-be-applied.json \
http://keycloak.keycloak.svc.cluster.local:8080/admin/realms/cnoe/users/${USER2ID}/reset-password
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should have a note in the README that both user1 and user2 get the same password and how maybe that can be tweaked

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated documentation

Signed-off-by: Manabu McCloskey <[email protected]>
3. **Crossplane**, AWS providers, and basic compositions for deploying cloud related resources (needs your credentials for this to work)
4. **External Secrets** to generate secrets and coordinate secrets between applications.
5. **Keycloak** as the identity provider for applications.
6. **Spark Operator** to demonstrate an example Spark workload through Backstage.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you use Apache Spark as example ? AFAIK, there is no backstage plugin, so what could be the added value to propose it as example ?
Remark: Should we instead propose as example a microservice such as Spring Boot, Quarkus, Nodejs or combination ?

@@ -0,0 +1,35 @@
{%- if values.awsResources %}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that we should dissociate the process to install the reference implementation (= components A + B + C etc) from the step to install an example top of the reference platform. Why ? As the goal of the tool is to provision a cluster, than such implementation should be used for different purposes, to allow the users to deploy also their own examples, or examples defined in a lab project, etc

Comment on lines +340 to +364
BACKSTAGE_CLIENT_SECRET=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET http://keycloak.keycloak.svc.cluster.local:8080/admin/realms/cnoe/clients/${CLIENT_ID} | jq -e -r '.secret')

ARGOCD_PASSWORD=$(./kubectl -n argocd get secret argocd-initial-admin-secret -o go-template='{{.data.password | base64decode }}')

ARGOCD_SESSION_TOKEN=$(curl -k -sS https://argocd-server.argocd.svc.cluster.local:443/api/v1/session -d "{\"username\":\"admin\",\"password\":\"${ARGOCD_PASSWORD}\"}" | jq -r .token)

echo \
"apiVersion: v1
kind: Secret
metadata:
name: keycloak-clients
namespace: keycloak
type: Opaque
stringData:
ARGO_WORKFLOWS_CLIENT_SECRET: ${ARGO_WORKFLOWS_CLIENT_SECRET}
ARGO_WORKFLOWS_CLIENT_ID: argo-workflows
ARGOCD_SESSION_TOKEN: ${ARGOCD_SESSION_TOKEN}
BACKSTAGE_CLIENT_SECRET: ${BACKSTAGE_CLIENT_SECRET}
BACKSTAGE_CLIENT_ID: backstage
" > /tmp/secret.yaml

./kubectl apply -f /tmp/secret.yaml

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the backstage secret created here within keycloak stuffs ? Such a step should be included within the backstage folder and documented to let the users to figure out how they could expand/override their app-config.yaml ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do you use Apache Spark as example ? AFAIK, there is no backstage plugin, so what could be the added value to propose it as example ?
Remark: Should we instead propose as example a microservice such as Spring Boot, Quarkus, Nodejs or combination ?

We do have a pugin for the Spark operator. This was included in the original reference implementation and thus it's included here. The purpose of it is to show that IDP does not necessary be for applications only.

I think that we should dissociate the process to install the reference implementation (= components A + B + C etc) from the step to install an example top of the reference platform. Why ? As the goal of the tool is to provision a cluster, than such implementation should be used for different purposes, to allow the users to deploy also their own examples, or examples defined in a lab project, etc

I think we need a guide to show this part, but not in this PR. The primary goal of this PR is to showcase what you can build with idpbuilder, even complicated stuff like this. If we want to create a guide for developing Backstage stuff, it should be separate.

Why is the backstage secret created here within keycloak stuffs ? Such a step should be included within the backstage folder and documented to let the users to figure out how they could expand/override their app-config.yaml ;-)

These are for SSO configuration stuff. Keycloak client secrets are generated by Keycloak upon creation of a client. We need a way to export this to client applications (backstage and argo workflows). We could include this in Backstage stuff but it becomes a bit of a mess because we now need to do the same for other apps like argocd and argo workflows.

@cmoulliard
Copy link
Contributor

As many of the backstage examples rely on scaffolding a project (spring boot, nodejs, quarkus, etc) on github, how will it be possible for a user to provide its GitHub Personal Access Token which is needed to configure such app-config.yaml field ?

integrations:
  github:
    - host: github.com
      token: <MY_GITHUB_PAT>

@nabuskey
Copy link
Collaborator Author

nabuskey commented Feb 13, 2024

As many of the backstage examples rely on scaffolding a project (spring boot, nodejs, quarkus, etc) on github, how will it be possible for a user to provide its GitHub Personal Access Token which is needed to configure such app-config.yaml field ?

GitHub integration stuff is left out intentionally. It's hard to automate and I did not want to make users worry about external stuff. I wanted everything to stay local. If they want integrations with external stuff like GitHub and AWS, they can look at the Terraform version.

What I wanted to enable for this was to show how you can bring up a solution with just one command.

@csantanapr
Copy link
Contributor

@nabuskey
tried this example, and hit a problem with argo workflows that server crashed.
I think this happens because keycloak took a while to come up, backstage had issues also but was eventually came up, argo workflows server doesn't work even with multiple restarts

k logs -n argo argo-server-6d8dbf6b99-2jdqh

time="2024-02-15T04:54:15.010Z" level=info msg="not enabling pprof debug endpoints"
time="2024-02-15T04:54:15.011Z" level=info authModes="[client sso]" baseHRef=/ managedNamespace= namespace=argo secure=false ssoNamespace=argo
time="2024-02-15T04:54:15.011Z" level=warning msg="You are running in insecure mode. Learn how to enable transport layer security: https://argo-workflows.readthedocs.io/en/release-3.5/tls/"
Error: 502 Bad Gateway: <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>

Usage:
  argo server [flags]

Examples:

@csantanapr
Copy link
Contributor

deleting the argo-server pod, made it work with the new pod

Signed-off-by: Manabu McCloskey <[email protected]>
@csantanapr
Copy link
Contributor

problems with keycloak got fix by the latest update to the image to 22.0.3 🙌

@csantanapr
Copy link
Contributor

@nabuskey
hitting a problem in Argo Sync with Backstage stays in an endless sync
The Kubernetes API could not find backstage.io/Location for requested resource backstage/basic-example-templates. Make sure the "Location" CRD is installed on the destination cluster.
Getting error
image

@csantanapr
Copy link
Contributor

nope, it looks like using keycloak 22.0.3 still has problems, container in crashloopback, logs:

Updating the configuration and installing your custom providers, if any. Please wait.
/opt/keycloak/bin/kc.sh: line 132:    19 Killed                  'java' -Dkc.config.build-and-exit=true -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.err.encoding=UTF-8 -Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8 -XX:+ExitOnOutOfMemoryError -Djava.security.egd=file:/dev/urandom -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED -Dkc.home.dir='/opt/keycloak/bin/..' -Djboss.server.config.dir='/opt/keycloak/bin/../conf' -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus-log-max-startup-records=10000 -cp '/opt/keycloak/bin/../lib/quarkus-run.jar' io.quarkus.bootstrap.runner.QuarkusEntryPoint --profile=dev start-dev

![img.png](images/backstage-templates.png)


In the next screen, type `demo` for the name field, then click create.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In the next screen, type `demo` for the name field, then click create.
In the next screen, type `demo` for the name field, then click Review, then Create.

Signed-off-by: Manabu McCloskey <[email protected]>
Signed-off-by: Manabu McCloskey <[email protected]>
@nabuskey nabuskey merged commit 6b704e6 into cnoe-io:main Feb 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants