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

Update creating.adoc #30

Merged
merged 6 commits into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 131 additions & 1 deletion docs/modules/ROOT/pages/how-tos/creating.adoc
Original file line number Diff line number Diff line change
@@ -1 +1,131 @@
= Creating applications and components
= Creating applications and components

To create an application in {ProductName}, someone must enable build pipelines in your instance of {ProductName}. At the time of publication, this process includes configuring a smee channel, to listen for users' pull requests, and creating a GitHub App, so {ProductName} can access those PRs. The first procedure in this document explains how to perform these tasks.

Once build pipelines are enabled, users can create their applications in {ProductName}. The second procedure below describes how to create an application.

== Enabling build pipelines for your instance of {ProductName}:

.Prerequisites:

* Install link:https://github.com/konflux-ci/konflux-ci/tree/main[{ProductName}]
* Read/write access to your {ProductName} instance’s repository
Chr1st1anSears marked this conversation as resolved.
Show resolved Hide resolved

.Procedure:

. Start a new link:https://smee.io/[smee] channel.
. In the repository for your instance of {ProductName}, edit the file /smee/smee-client.yaml. Replace `<smee-channel>` with the webhook proxy URL from the previous step.
. Create a GitHub App according to link:https://pipelinesascode.com/docs/install/github_apps/#manual-setup[these Pipelines as Code instructions]. For the *Webhook URL* field, use the webhook proxy URL for your smee channel.
Comment on lines +7 to +18
Copy link
Member

Choose a reason for hiding this comment

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

This is intended for the platform engineer to complete while users would complete later ones, right?


== Creating your applications and components with {ProductName}:

At the time of publication, to create applications in {ProductName}, you need to manually maintain their configurations by editing YAML files. This might change, in favor of maintaining those configurations in the {ProductName} UI.

.Prerequisites:

* link:https://kubernetes.io/docs/tasks/tools/[kubectl] CLI tool
* The following values from your {ProductName} GitHub App:
** The private key
** The App ID
** The webhook secret
* A GitHub repository with source code for your application
** It must have the same basic structure as our example repository
* Read/write access to the repository for your instance of {ProductName}

.Procedure:

. In the GitHub repository for your application, install your organization’s {ProductName} GitHub App.
. In the repository for your instance of {ProductName}, prepare an `application-and-component.yaml` file for your namespace.
.. If your namespace does not already have this YAML file, create it with the following path: `/test/resources/demo-users/user/<namespace>/application-and-component.yaml`. Use the namespace 2 file as a template.
.. Replace the two `url` values in that YAML file as follows:
... For the `url` value beneath `git`, provide the URL that you would use to locally clone your application’s repository. This URL ends with `.git`.
... For the `url` value beneath `spec`, at the end of the file, provide the URL for your application’s repository that you see in your browser, without `.git` at the end.
+
NOTE: To add other components to the same namespace, reference the example YAML file beneath this procedure.
. Login to the Kubernetes cluster where Konflux is deployed.
. Run the following command. Be sure to replace <namespace> with your actual namespace.
+
`kubectl create -f /test/resources/demo-users/user/<namespace>/application-and-component.yaml`
. Run the following command. But first, be sure to export as variables or hard code the values for `PATH_PRIVATE_KEY`, `APP_ID`, and `WEBHOOK_SECRET`.
+
[source]
--
kubectl -n pipelines-as-code create secret generic pipelines-as-code-secret \
--from-literal github-private-key="$(cat $PATH_PRIVATE_KEY)" \
--from-literal github-application-id="APP_ID" \
--from-literal webhook.secret="WEBHOOK_SECRET"
--
. Still in the context of your {ProductName} repository, run `kubectl create -f smee/smee-client`.
. Now, you can trigger your application’s first build pipeline. In the git repository for your application, using your preferred text editor, open a pull request against the `/.tekton/pull-request.yaml` file.
.. Specifically, replace any existing value for the `git-url` field with the git URL for your application’s repository. (This is the URL you would use to clone the repository locally; it ends with `.git`.)
Comment on lines +20 to +60
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the process to create the GitHub application, not to create Components and Applications.

. Once the PR is made, a build pipeline should start. You can track its progress on GitHub, or in the {ProductName} UI. If the pipeline is successful, you can merge the PR.

== Example YAML file for multiple components

If you want to create an application that contains multiple components, model your `application-and-component.yaml` file after the following example.

[source]
--
---
apiVersion: appstudio.redhat.com/v1alpha1
kind: Application
metadata:
name: test-application
namespace: user-ns2
annotations:
application.thumbnail: "1"
spec:
displayName: test-application
---
apiVersion: appstudio.redhat.com/v1alpha1
kind: Component
metadata:
name: test-component1
namespace: user-ns2
annotations:
build.appstudio.openshift.io/request: configure-pac
image.redhat.com/generate: '{"visibility": "public"}'
spec:
application: test-application
componentName: test-component1
source:
git:
revision: main
url: https://github.com/konflux-ci/testrepo.git
dockerfileUrl: Dockerfile
context: ./
---
apiVersion: appstudio.redhat.com/v1alpha1
kind: Component
metadata:
name: test-component2
namespace: user-ns2
annotations:
build.appstudio.openshift.io/request: configure-pac
image.redhat.com/generate: '{"visibility": "public"}'
spec:
application: test-application
componentName: test-component2
source:
git:
revision: main
url: https://github.com/konflux-ci/anothertestrepo.git
dockerfileUrl: Dockerfile
context: ./
---
apiVersion: "pipelinesascode.tekton.dev/v1alpha1"
kind: Repository
metadata:
name: project-repository-testrepo
namespace: user-ns2
spec:
url: "https://github.com/konflux-ci/testrepo"
---
apiVersion: "pipelinesascode.tekton.dev/v1alpha1"
kind: Repository
metadata:
name: project-repository-anothertestrepo
namespace: user-ns2
spec:
url: "https://github.com/konflux-ci/anothertestrepo"
--
Loading