Skip to content

Commit 00e97bd

Browse files
committed
add guide for building and installing Crossplane from source code
Signed-off-by: Jared Watts <[email protected]>
1 parent 5951257 commit 00e97bd

File tree

2 files changed

+211
-0
lines changed

2 files changed

+211
-0
lines changed

content/master/get-started/install.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,9 @@ at the table below.
117117
Set these flags either in the `values.yaml` file or at install time using the
118118
`--set` flag, for example: `--set
119119
args='{"--enable-composition-functions","--enable-composition-webhook-schema-validation"}'`.
120+
121+
## Build and install from source
122+
123+
Building Crossplane from the source code gives you complete control over the build and
124+
installation process. Full instructions for this advanced installation path can
125+
be found in the [install from source code guide]({{<ref "../guides/install-from-source.md">}}).
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
---
2+
title: Install Crossplane from source code
3+
weight: 510
4+
description: "Build and install Crossplane from source code into a control plane"
5+
---
6+
7+
Building Crossplane from the source code gives you complete control over the
8+
build and installation process.
9+
10+
You build the Crossplane container image and Helm chart directly from the source
11+
code, push the image to your own registry, and install to your Kubernetes
12+
cluster.
13+
14+
{{< hint "important" >}}
15+
This is an advanced installation path for users who
16+
require complete control over the build and deployment process. Most users
17+
should follow the [standard installation instructions]({{<ref "../get-started/install.md">}})
18+
{{< /hint >}}
19+
20+
This approach is useful when you want to:
21+
- Control the entire build and deployment pipeline
22+
- Use your own container registry and cluster
23+
- Deploy to air-gapped or restricted environments
24+
- Build from a specific commit or branch
25+
26+
### Prerequisites
27+
28+
Building Crossplane from source requires:
29+
30+
- [Docker](https://docs.docker.com/get-docker/)
31+
- [Earthly](https://earthly.dev/get-earthly) version `v0.8.16` or later
32+
- [kubectl](https://kubernetes.io/docs/tasks/tools/) configured for your target cluster
33+
- An actively [supported Kubernetes version](https://kubernetes.io/releases/patch-releases/#support-period)
34+
- [Helm](https://helm.sh/docs/intro/install/) version `v3.2.0` or later
35+
- Access to a container registry (Docker Hub, GHCR, Harbor, or any OCI-compliant
36+
registry)
37+
38+
### Clone the Crossplane repository
39+
40+
Clone the Crossplane repository and optionally check out a specific release.
41+
42+
```shell {copy-lines="all"}
43+
git clone https://github.com/crossplane/crossplane.git
44+
cd crossplane
45+
```
46+
47+
{{< hint "tip" >}}
48+
To build a specific release, check out the release tag before building.
49+
50+
```shell
51+
git checkout v2.0.2
52+
```
53+
{{< /hint >}}
54+
55+
### Determine your cluster architecture
56+
57+
Identify your cluster's CPU architecture before building. Crossplane must be
58+
built for the same architecture as your cluster nodes. Here is one possible way to check the
59+
architecture of your cluster:
60+
61+
```shell {copy-lines="1"}
62+
kubectl get nodes -o jsonpath='{.items[0].status.nodeInfo.architecture}'
63+
arm64
64+
```
65+
66+
Save this architecture in an environment variable:
67+
68+
```shell
69+
export CLUSTER_ARCH=<your cluster arch>
70+
```
71+
72+
### Determine artifacts destination
73+
74+
Identify the registry and version tag where you will be pushing your built
75+
software artifacts and save them in environment variables:
76+
77+
```shell {copy-lines="all"}
78+
export REGISTRY="your-registry.com/your-org"; \
79+
export VERSION="v2.0.0-yourtag"
80+
```
81+
82+
### Build the artifacts
83+
84+
Build Crossplane binaries for your cluster's architecture:
85+
86+
```shell {copy-lines="all"}
87+
earthly --platform=linux/${CLUSTER_ARCH} +go-build --CROSSPLANE_VERSION=${VERSION}
88+
```
89+
90+
Build the Crossplane container image:
91+
92+
```shell {copy-lines="all"}
93+
earthly --platform=linux/${CLUSTER_ARCH} +image \
94+
--CROSSPLANE_REPO=${REGISTRY}/crossplane \
95+
--CROSSPLANE_VERSION=${VERSION}
96+
```
97+
98+
Build the Helm chart:
99+
```shell {copy-lines="all"}
100+
earthly +helm-build --CROSSPLANE_VERSION=${VERSION}
101+
```
102+
103+
Earthly creates the container image locally and saves the binaries and Helm
104+
chart under `_output/bin` and `_output/charts/` respectively.
105+
106+
### Push the image to your registry
107+
108+
Log in to your registry of choice and push the Crossplane image that we built in the previous steps.
109+
110+
{{< hint "tip" >}}
111+
Ensure you log into your registry before attempting to `push`.
112+
{{< /hint >}}
113+
114+
```shell {copy-lines="all"}
115+
docker push ${REGISTRY}/crossplane:${VERSION}
116+
```
117+
118+
### Install Crossplane with the custom image
119+
120+
Locate the built Helm chart in the `_output/charts/` directory.
121+
122+
```shell {copy-lines="all"}
123+
CHART_PATH="_output/charts/crossplane-${VERSION#v}.tgz"
124+
```
125+
126+
Install Crossplane to your cluster using the custom image.
127+
128+
```shell {copy-lines="all"}
129+
helm install crossplane ${CHART_PATH} \
130+
--namespace crossplane-system \
131+
--create-namespace \
132+
--set image.repository=${REGISTRY}/crossplane \
133+
--set image.tag=${VERSION} \
134+
--set image.pullPolicy=IfNotPresent
135+
```
136+
137+
{{< hint "important" >}} If your registry requires authentication, create an
138+
`imagePullSecret` before installing.
139+
140+
```shell
141+
kubectl create secret docker-registry regcred \
142+
--docker-server=${REGISTRY} \
143+
--docker-username=<username> \
144+
--docker-password=<password> \
145+
--namespace crossplane-system
146+
```
147+
148+
Add the secret reference to the `helm install` command.
149+
150+
```shell
151+
--set imagePullSecrets[0].name=regcred
152+
```
153+
{{< /hint >}}
154+
155+
### Verify the installation
156+
157+
View the installed Crossplane pods with `kubectl get pods`.
158+
159+
```shell {copy-lines="1"}
160+
kubectl get pods -n crossplane-system
161+
NAME READY STATUS RESTARTS AGE
162+
crossplane-5644774bd4-zvcwc 1/1 Running 0 72s
163+
crossplane-rbac-manager-84dc89c564-b9x6q 1/1 Running 0 72s
164+
```
165+
166+
Verify the Crossplane deployment is using your custom image.
167+
168+
```shell {copy-lines="1"}
169+
kubectl get deployment crossplane -n crossplane-system -o jsonpath='{.spec.template.spec.containers[0].image}'
170+
your-registry.com/your-org/crossplane:v2.0.0-yourtag
171+
```
172+
173+
### Optional: Build the Crossplane CLI
174+
175+
The `crossplane` CLI provides additional commands for managing Crossplane
176+
resources. You can optionally build this binary from source code for your local
177+
machine and use it to manage your control plane.
178+
179+
Build the CLI for your local machine.
180+
181+
```shell {copy-lines="all"}
182+
earthly +build --CROSSPLANE_VERSION=${VERSION}
183+
```
184+
185+
Earthly creates the CLI binary in `_output/bin/<OS>_<ARCH>/`. Copy it to your
186+
system path.
187+
188+
For macOS ARM64:
189+
```shell {copy-lines="all"}
190+
sudo cp _output/bin/darwin_arm64/crank /usr/local/bin/crossplane
191+
chmod +x /usr/local/bin/crossplane
192+
```
193+
194+
For Linux AMD64:
195+
```shell {copy-lines="all"}
196+
sudo cp _output/bin/linux_amd64/crank /usr/local/bin/crossplane
197+
chmod +x /usr/local/bin/crossplane
198+
```
199+
200+
Verify the installation.
201+
202+
```shell {copy-lines="1"}
203+
crossplane version
204+
v2.0.0-yourtag
205+
```

0 commit comments

Comments
 (0)