|
| 1 | +# Access resource with Private IP from OCI Build runner |
| 2 | + |
| 3 | +This sample shows how to access resources which are with private IP addresses from an OCI Build runner. |
| 4 | + |
| 5 | +## Accessing Private Virtual Network from Build runner |
| 6 | + |
| 7 | +- You can access self-hosted repositories (GitLab Server and Bitbucket Server) with private IP from the Managed Build stage. With the private access configuration, you can write commands in the build specification file to access the private endpoints in your Virtual Cloud Network (VCN). During the build, the service-managed build runner facilitates the connection from the build stage to your tenancy subnet. Using FastConnect or other IPSec VPN peering solutions, you can also create a connection to access your on-premises code repository from an OCI DevOps build runner. |
| 8 | + |
| 9 | +## Specific instruction to clone only this example. |
| 10 | + |
| 11 | + ``` |
| 12 | + $ git init oci-devops-pa-with-private-oke |
| 13 | + $ cd oci-devops-pa-with-private-oke |
| 14 | + $ git remote add origin <url to this git repo> |
| 15 | + $ git config core. sparsecheckout true |
| 16 | + $ echo "oci-build-examples/oci-devops-pa-with-private-oke/*">>.git/info/sparse-checkout |
| 17 | + $ git pull --depth=1 origin main |
| 18 | +
|
| 19 | + ``` |
| 20 | + |
| 21 | +## Objectives |
| 22 | + |
| 23 | +- Create an [Container Engine for Kubernetes (OKE)](https://docs.oracle.com/en-us/iaas/Content/ContEng/home.htm) |
| 24 | +- Associate OCI DevOps Build runner via Private Access endpoints. |
| 25 | +- Test and validate the access |
| 26 | + |
| 27 | + |
| 28 | +## Procedure to use this illustration. |
| 29 | + |
| 30 | +###OCI Notifications |
| 31 | +- Create an OCI notification topic - https://docs.oracle.com/en-us/iaas/Content/Notification/Tasks/managingtopicsandsubscriptions.htm#createTopic |
| 32 | + |
| 33 | +### OCI Container Engine for Kubernetes (OKE) |
| 34 | +- Create Container Engine for Kubernetes (OKE) Cluster using Quick workflow - https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingclusterusingoke_topic-Using_the_Console_to_create_a_Quick_Cluster_with_Default_Settings.htm#create-quick-cluster |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +- Select `Private endpoints` and `Private workers`. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +- Make a note of OKE's Cluster Id. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +💡Specific note on the network setup |
| 48 | +- When you build OKE via wizard it will set up necessary VCN, subnet, gateways, route tables etc. |
| 49 | +- But if you are using custom workflow for OKE or connection for any other resources from build runner, ensure to set up NAT or Service gateway accordingly. |
| 50 | +- When using with a Private access endpoint, the Build runner instance is considered as a private instance in your VCN during the network setup. Using only an internet gateway does not allow egress to the internet from a private subnet. Therefore, the VCN must have a Network Address Translation (NAT) gateway or service gateway with routing rules to forward traffic configured in the routing table for the private access configuration to succeed in the Managed Build stage. |
| 51 | + |
| 52 | +### Validate VCN |
| 53 | + |
| 54 | +- As we have used the `Quick workflow`, it has created the VCN and necessary details. |
| 55 | +- From `OKE details` identify `VCN Name` and click on the link. |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +- There will be 3 subnets, one for endpoint, one for the load balancer and another one for nodes. |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +- Check the `Route tables` and check the `Route Table` for private subnets. There will be a `NAT Gateway` for access to the internet and a `Service Gateway` to access the OCI services. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +### OCI DevOps. |
| 68 | + |
| 69 | +- Create a DevOps project - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_project.htm#create_a_project. |
| 70 | + Associate with the notification topic. |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +- Ensure to enable the logs for the DevOps project. |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +- Create an OCI code repo - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_repo.htm#create_repo and push this content to the repo. |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +- Create an OCI Build pipeline - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_buildpipeline.htm |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +- Add the below parameters to the build pipeline with proper values. |
| 87 | + |
| 88 | + - KUBECTL_VERSION - Version of the kubectl to be used - https://kubernetes.io/releases/,Example:1.24.0 |
| 89 | + - OCI_OKE_OCID - Cluster ID of the OKE, Example: ocid1.cluster.oc1.us-sanjose-1.xx |
| 90 | + - OCI_REGION - OCI Region, Example: us-sanjose-1 |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +- Use the `+` and add a `Managed Build` stage. |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +- Provide a `Stage name` and `Stage description(Optional)`. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +- Click on `Connect to your tenancy subnet` |
| 106 | +- Select the VCN same as that of our private OKE. |
| 107 | +- Select oke-node subnet. |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +- Click `Select` under `Primary code repository` and select the code repo of type `OCI Code Repository` created. |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +- Click `Add` |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | +- Here the `Focus` is on accessing private IP-based resources from the build pipeline, to do so we are using sample kubectl actions, but the same can be extended as a full pipeline with other stages and connected to the deployment pipeline as well. |
| 120 | + |
| 121 | +### Let's test |
| 122 | + |
| 123 | +- Within the build pipeline, click `Start manual run` and start the pipeline. |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | +- Wait for all the steps to complete. |
| 128 | + |
| 129 | +- View the build execution logs and validate the access. |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | +References |
| 134 | +========== |
| 135 | + |
| 136 | +- Oracle Cloud Infrastructure DevOps - https://docs.oracle.com/en-us/iaas/Content/devops/using/home.htm |
| 137 | + |
| 138 | + |
| 139 | +Contributors |
| 140 | +=========== |
| 141 | + |
| 142 | +- Author: [Rahul M R](https://github.com/RahulMR42). |
| 143 | +- Collaborators: NA |
| 144 | +- Last release: August 2022 |
| 145 | + |
| 146 | +### Back to examples. |
| 147 | +---- |
| 148 | + |
| 149 | +- 🍿 [Back to OCI DevOps Build sample](./../README.md) |
| 150 | +- 🏝️ [Back to OCI DevOps sample](./../../README.md) |
| 151 | + |
| 152 | + |
| 153 | + |
0 commit comments