Skip to content

Commit c62184f

Browse files
committed
Add installation content
Ported runner and on-premt topics from Classic and moved CSDP runtime topics to Installation folder
1 parent f04c329 commit c62184f

12 files changed

+4132
-0
lines changed
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
---
2+
title: "Codefresh Behind the Firewall"
3+
description: "How to run Codefresh Pipelines in your own secure Infrastructure"
4+
group: installation
5+
redirect_from:
6+
- /docs/enterprise/behind-the-firewall/
7+
toc: true
8+
9+
---
10+
11+
As explained in the [installation page]({{site.baseurl}}/docs/administration/installation-security/) Codefresh offers three installation options; pure cloud, on-premise and Hybrid.
12+
In this document, we will describe the Hybrid option and all the advantages it offers.
13+
14+
## Running Codefresh in secure environments
15+
16+
Codefresh has an on-premise installation where the whole platform is installed on the customer premises. While
17+
this solution is very effective as far as security is concerned, it places a lot of overhead on the customer, as all updates
18+
and improvements done in the platform must also be transferred to the customer premises.
19+
20+
This Hybrid approach places a Codefresh runner within customer premises while the UI (and management platform) stays in the Codefresh SaaS.
21+
22+
Here is the overall architecture:
23+
24+
{% include image.html
25+
lightbox="true"
26+
file="/images/administration/behind-the-firewall/architecture.png"
27+
url="/images/administration/behind-the-firewall/architecture.png"
28+
alt="Codefresh behind the firewall"
29+
caption="Codefresh behind the firewall"
30+
max-width="100%"
31+
%}
32+
33+
The advantages for this scenario are multi-fold. Regarding platform maintenance:
34+
35+
1. The heavy lifting for platform maintenance is still happening by Codefresh instead of the customer.
36+
1. Updates to the UI, build engine, integrations etc., are happening automatically without any customer involvement.
37+
1. Actual builds are happening in the customer premises under fully controlled conditions.
38+
1. The Codefresh runner is fully automated. It handles volume claims and build scheduling on its own within the Kubernetes cluster it is placed.
39+
40+
Regarding security of services:
41+
42+
1. Pipelines can run in behind-the-firewall clusters with internal services.
43+
1. Pipelines can use integrations (such as Docker registries) that are private and secure.
44+
1. Source code does not ever leave the customer premises.
45+
46+
Regarding firewall security:
47+
48+
1. Communication between the Codefresh runner and Codefresh SaaS is uni-directional. The runner is polling the Codefresh platform for jobs.
49+
1. Communication between the Codefresh runner and Codefresh SaaS is only outgoing. The Codefresh SaaS never connects to the customer network. No ports need to be open in the customer firewall for the runner to work.
50+
1. The Codefresh runner is fully open-sourced, so its code can by scrutinized by any stakeholder.
51+
52+
53+
54+
## Using Secure services in your pipelines
55+
56+
First make sure that you have installed the [Codefresh runner]({{site.baseurl}}/docs/administration/codefresh-runner/) on your own infrastructure (i.e., your private Kubernetes cluster).
57+
58+
All pipelines that are executed in the private Kubernetes cluster have access to all other internal services that are network reachable. It is therefore very easy to create pipelines that:
59+
60+
* Use databases internal to the company
61+
* Run integration tests against services internal to the company
62+
* Launch [compositions]({{site.baseurl}}/docs/codefresh-yaml/steps/composition/) that communicate with other secure services
63+
* Upload and download artifacts from a private artifact repository (e.g., Nexus or Artifactory)
64+
* Deploy to any other cluster accessible in the secure network
65+
* Create infrastructure such as machines, load balancers, auto-scaling groups etc.
66+
67+
Any of these pipelines will work out the box and no extra configuration is needed. In all cases,
68+
all data will stay with the private local network and will never exit the firewall.
69+
70+
>Notice that [long running compositions]({{site.baseurl}}/docs/codefresh-yaml/steps/composition/) (preview test environments) are not yet available via the Codefresh
71+
build runner.
72+
73+
74+
75+
### Checking out code from a private GIT repository
76+
77+
To check-out code from your private GIT repository, you need to connect first to Codefresh via the [GIT integrations]({{site.baseurl}}/docs/integrations/git-providers/). However, once you define your GIT provider as *on premise* you also
78+
need to mark it as *behind the firewall* as well:
79+
80+
{% include image.html
81+
lightbox="true"
82+
file="/images/administration/behind-the-firewall/behind-the-firewall-toggle.png"
83+
url="/images/administration/behind-the-firewall/behind-the-firewall-toggle.png"
84+
alt="Behind the firewall toggle"
85+
caption="Behind the firewall toggle"
86+
max-width="100%"
87+
%}
88+
89+
Once you do that save your provider and make sure that it has the correct tags. The name you used for the git provider will also be used in the pipeline. You cannot "test the connection" because
90+
the Codefresh SAAS doesn't have access to your on-premises GIT repository.
91+
92+
{% include image.html
93+
lightbox="true"
94+
file="/images/administration/behind-the-firewall/behind-the-firewall-tag.png"
95+
url="/images/administration/behind-the-firewall/behind-the-firewall-tag.png"
96+
alt="Behind the firewall tags"
97+
caption="Behind the firewall tags"
98+
max-width="100%"
99+
%}
100+
101+
To check out code just use a [clone step]({{site.baseurl}}/docs/codefresh-yaml/steps/git-clone/) like any other clone operation.
102+
The only thing to remember is that the GIT URL must be fully qualified. You need to [create a pipeline]({{site.baseurl}}/docs/configure-ci-cd-pipeline/pipelines/#pipeline-creation-modes) on it its own from the *Pipelines* section of the left sidebar (instead of one adding a git repository to Codefresh)
103+
104+
105+
106+
`YAML`
107+
{% highlight yaml %}
108+
{% raw %}
109+
version: '1.0'
110+
steps:
111+
main_clone:
112+
type: git-clone
113+
description: Step description
114+
repo: https://github-internal.example.com/my-username/my-app
115+
git: my-internal-git-provider
116+
BuildingDockerImage:
117+
title: Building Docker Image
118+
type: build
119+
image_name: my-image
120+
tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}'
121+
dockerfile: Dockerfile
122+
{% endraw %}
123+
{% endhighlight %}
124+
125+
Once you trigger the pipeline, the Codefresh builder will communicate with your private GIT instance and checkout code.
126+
127+
>Note that currently there is a limitation in regards to the location of the `codefresh.yml` file. Only the [inline mode]({{site.baseurl}}/docs/configure-ci-cd-pipeline/pipelines/#writing-codefresh-yml-in-the-gui) is supported. Soon we will allow the loading of the pipeline from the git repository itself.
128+
129+
You can also use a [network proxy]({{site.baseurl}}/docs/codefresh-yaml/steps/git-clone/#using-git-behind-a-proxy) for the Git clone step.
130+
131+
#### Adding triggers from private GIT repositories
132+
133+
134+
In the previous section we have seen how a pipeline can check out code from the internal git repository. We also need to setup a trigger
135+
so that every time a commit happens (or any other supported event), the Codefresh pipeline will be triggered automatically.
136+
137+
If you have installed the [optional app-proxy]({{site.baseurl}}/docs/administration/codefresh-runner/#optional-installation-of-the-app-proxy), adding a trigger can be done exactly like the SAAS version of Codefresh, using only the Codefresh UI.
138+
139+
If you haven't installed the app-proxy, then adding a Git trigger is a two-step process:
140+
141+
1. First we setup a webhook endpoint in Codefresh.
142+
1. Then we create the webhook call in the side of the the GIT provider.
143+
144+
> To support triggers based on PR (Pull Request) events, it is mandatory to install `app-proxy`.
145+
146+
For the Codefresh side, follow the usual instructions for creating a [basic git trigger]({{site.baseurl}}/docs/configure-ci-cd-pipeline/triggers/git-triggers/).
147+
148+
Once you select your GIT provider, you need to manually enter your username and repository that you wish to trigger the build.
149+
150+
{% include image.html
151+
lightbox="true"
152+
file="/images/administration/behind-the-firewall/enter-repo-details.png"
153+
url="/images/administration/behind-the-firewall/enter-repo-details.png"
154+
alt="Entering repository details"
155+
caption="Entering repository details"
156+
max-width="60%"
157+
%}
158+
159+
All other details (git events, branch naming, monorepo pattern, etc.) are still the same as normal SAAS GIT providers.
160+
Once that is done, Codefresh will show you the webhook endpoint along with a secret for triggering this pipeline. Note them down.
161+
162+
163+
{% include image.html
164+
lightbox="true"
165+
file="/images/administration/behind-the-firewall/codefresh-webhook.png"
166+
url="/images/administration/behind-the-firewall/codefresh-webhook.png"
167+
alt="Codefresh webhook details"
168+
caption="Codefresh webhook details"
169+
max-width="60%"
170+
%}
171+
172+
This concludes the setup on the Codefresh side. The final step is create a webhook call on the side of your GIT provider.
173+
The instructions are different per GIT provider:
174+
175+
* [GitHub webhooks](https://developer.github.com/webhooks/)
176+
* [GitLab webhooks](https://docs.gitlab.com/ee/user/project/integrations/webhooks.html)
177+
* [Stash webhooks](https://confluence.atlassian.com/bitbucketserver/managing-webhooks-in-bitbucket-server-938025878.html)
178+
179+
In all cases make sure that the payload is JSON, because this is what Codefresh expects.
180+
181+
* For GitHub the events monitored should be `Pull requests` and `Pushes`.
182+
* For GitLab the events monitored should be `Push events`,`Tag push events` and `Merge request events`.
183+
184+
After the setup is finished, the Codefresh pipeline will be executed every time a git event happens.
185+
186+
### Accessing an internal docker registry
187+
188+
To access an internal registry just follow the instructions for [adding registries]({{site.baseurl}}/docs/docker-registries/external-docker-registries/) . Like GIT repositories
189+
you need to mark the Docker registry as *Behind the firewall*.
190+
191+
Once that is done, use the [push step]({{site.baseurl}}/docs/codefresh-yaml/steps/push/) as usual with the name you gave to the registry during the integration setup.
192+
193+
194+
`YAML`
195+
{% highlight yaml %}
196+
{% raw %}
197+
version: '1.0'
198+
steps:
199+
gitClone:
200+
type: git-clone
201+
description: Step description
202+
repo: https://github-internal.example.com/my-username/my-app
203+
git: my-internal-git-repo
204+
BuildingDockerImage:
205+
title: Building Docker Image
206+
type: build
207+
image_name: my-image
208+
dockerfile: Dockerfile
209+
PushingDockerImage:
210+
title: Pushing a docker image
211+
type: push
212+
candidate: '${{BuildingDockerImage}}'
213+
tag: '${{CF_BRANCH}}'
214+
registry: my-internal-docker-registry
215+
{% endraw %}
216+
{% endhighlight %}
217+
218+
219+
### Deploying to an internal Kubernetes cluster
220+
221+
To connect a cluster that is behind the firewall follow the [connecting cluster guide]({{site.baseurl}}/docs/deploy-to-kubernetes/add-kubernetes-cluster/), paying attention to the following two points:
222+
223+
1. Your cluster should be added as a [Custom provider]({{site.baseurl}}/docs/deploy-to-kubernetes/add-kubernetes-cluster/#adding-any-other-cluster-type-not-dependent-on-any-provider)
224+
1. You need to mark the cluster as internal by using the toggle switch.
225+
226+
227+
228+
229+
{% include image.html
230+
lightbox="true"
231+
file="/images/administration/behind-the-firewall/cluster-behind-firewall.png"
232+
url="/images/administration/behind-the-firewall/cluster-behind-firewall.png"
233+
alt="Marking a Kubernetes cluster as internal"
234+
caption="Marking a Kubernetes cluster as internal"
235+
max-width="60%"
236+
%}
237+
238+
The cluster where the runner works on should have network connectivity with the cluster you wish to deploy to.
239+
240+
>Notice that the service account used in the cluster configuration is completely independent from the privileges granted to the Codefresh build runner. The privileges needed by the runner are only used to launch Codefresh pipelines within your cluster. The Service account used in the "custom provider" setting should have the needed privileges for deployment.
241+
242+
Once your cluster is connected you can use any of the familiar deployment methods such as the [dedicated deploy step]({{site.baseurl}}/docs/deploy-to-kubernetes/deployment-options-to-kubernetes/) or [custom kubectl commands]({{site.baseurl}}/docs/deploy-to-kubernetes/custom-kubectl-commands/).
243+
244+
## What to read next
245+
246+
* [Codefresh installation options]({{site.baseurl}}/docs/administration/installation-security/)
247+
* [Google marketplace integration]({{site.baseurl}}/docs/integrations/google-marketplace/)
248+
* [Managing your Kubernetes cluster]({{site.baseurl}}/docs/deploy-to-kubernetes/manage-kubernetes/)

0 commit comments

Comments
 (0)