diff --git a/docs/cloud/rahti2/images/creating.md b/docs/cloud/rahti2/images/creating.md index cac87dd6da..a63c3a7e24 100644 --- a/docs/cloud/rahti2/images/creating.md +++ b/docs/cloud/rahti2/images/creating.md @@ -175,6 +175,135 @@ It is also possible to create a build from a given `Dockerfile`: cat Dockerfile | oc new-build -D - ``` +### Import from Git (Private Repositories) using the Web GUI + +Deploying a private Git repository to Rahti involves setting up the necessary authentication to access your private repository. Without proper authentication, you will see the error "URL is valid but cannot be reached" (seen in the pictures below). Here's how to resolve this using two authentication methods: + + +![oie_1671443U3OLpFT1](https://github.com/user-attachments/assets/a844e224-769e-4d9f-bba2-043ad5c9b258) + + +#### Option 1: Using a Token for Git Authentication + +1. **Generate a Personal Access Token:** + + - **GitHub:** + - Go to your GitHub account settings. + - Navigate to "Developer settings" > "Personal access tokens". + - Click on "Generate new token". + - Select the scopes you need (typically, you'll need `repo` scope for private repositories). + - Generate the token and copy it. + + - **GitLab:** + - Go to your GitLab profile settings. + - Navigate to "Access Tokens". + - Give your token a name, select the required scopes (e.g., `api`, `read_repository`), and create the token. + - Copy the token. + +3. **Add the Token to Rahti:** + - Under "Source Secret" choose "Create new Secret" + - Name the secret, under "Authentication type" choose "Basic Authentication" + - Paste the token and create + +![oie_1672121lETtYQ6J](https://github.com/user-attachments/assets/4bd9450f-170b-4a9e-ae8c-df4700fb0be4) + + +#### Option 2: Using a Private SSH Key for Git Authentication + +1. **Generate an SSH Key Pair (if you don't have one already):** + + - Open a terminal and run the following command to generate a new SSH key pair: + ```sh + ssh-keygen -t rsa -b 4096 -C "your_email@example.com" + ``` + - This will create two files: a private key (`id_rsa`) and a public key (`id_rsa.pub`). + +2. **Add Your Public Key to Your Git Hosting Service:** + + - **GitHub:** + - Go to your GitHub account settings. + - Navigate to "SSH and GPG keys". + - Click "New SSH key" and paste the contents of your `id_rsa.pub` file. + + - **GitLab:** + - Go to your GitLab profile settings. + - Navigate to "SSH Keys". + - Add a new SSH key and paste the contents of your `id_rsa.pub` file. + +4. **Add the Private SSH Key to Rahti:** + - Under "Source Secret" choose "Create new Secret" + - Name the secret, under "Authentication type" choose "SSH Key" + - Paste the contents of your private SSH key (`id_rsa`) and create + - +![oie_16720584BbbOspb](https://github.com/user-attachments/assets/b1d47511-0ce6-4980-a732-895193895780) + + +### Import from Git (Private Repositories) using the CLI + +This assumes that the users has generated SSH keys and registered their public key with GitHub. + + +**[Log into OpenShift CLI (`oc`)](../usage/cli.md#how-to-login-with-oc)**: + +```bash +oc login +``` + +**[Create a New Project](../usage/projects_and_quota.md#creating-a-project)**: + +```bash +oc new-project --display-name= --description="csc_project:" +``` + +**Create SSH Key Secret**: + +```bash +oc create secret generic --from-file=ssh-privatekey= --type=kubernetes.io/ssh-auth +``` + +**Link the Secret to the Builder Service Account**: + +```bash +oc secrets link builder +``` + + +**Deploy the Application**: + +```bash +oc new-app --name= +``` + +**Monitor the Build**: + +- monitor logs + ```bash + oc logs -f buildconfig.build.openshift.io/ + ``` + +- The initial build will probably fail due to authentication issues, set the build secret explicitly: + ```bash + oc set build-secret --source bc/ + ``` + +- Trigger a new build: + ```bash + oc start-build --follow + ``` + +**Expose the Application**: + +```bash +oc expose deployment --name= --port= --target-port= +oc expose svc/ +``` + +**Access the Application**: + +- Use the URL provided by: + ```bash + oc get route + ``` ## Troubleshooting