Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit a52bd97

Browse files
authored
Merge pull request #60 from packethost/examples
update examples and README for XP 1.2 and EM provider 0.0.7
2 parents d24ee2d + 5ae5a4e commit a52bd97

File tree

6 files changed

+122
-47
lines changed

6 files changed

+122
-47
lines changed

README.md

Lines changed: 77 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Crossplane Equinix Metal Provider
22

33
[![GitHub release](https://img.shields.io/github/release/packethost/crossplane-provider-equinix-metal/all.svg?style=flat-square)](https://github.com/packethost/crossplane-provider-equinix-metal/releases)
4+
[![crds.dev](https://img.shields.io/badge/Docs-crds.dev-blue)](https://doc.crds.dev/github.com/packethost/crossplane-provider-equinix-metal)
45
[![Go Report Card](https://goreportcard.com/badge/github.com/packethost/crossplane-provider-equinix-metal)](https://goreportcard.com/report/github.com/packethost/crossplane-provider-equinix-metal)
56
[![Slack](https://slack.equinixmetal.com/badge.svg)](https://slack.equinixmetal.com)
67
[![Twitter Follow](https://img.shields.io/twitter/follow/packethost.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=equinixmetal)
78
![](https://img.shields.io/badge/Stability-Maintained-green.svg)
89

910
## Overview
1011

11-
[From Crossplane's Provider documentation](https://crossplane.io/docs/v0.14/introduction/providers.html):
12+
[From Crossplane's Provider documentation](https://crossplane.io/docs/v1.2/concepts/providers.html):
1213

13-
> Providers extend Crossplane to enable infrastructure resource provisioning. In order to provision a resource, a Custom Resource Definition(CRD) needs to be registered in your Kubernetes cluster and its controller should be watching the Custom Resources those CRDs define. Provider packages contain many Custom Resource Definitions and their controllers.
14+
> Providers extend Crossplane to enable infrastructure resource provisioning. In order to provision a resource, a Custom Resource Definition (CRD) needs to be registered in your Kubernetes cluster and its controller should be watching the Custom Resources those CRDs define. Provider packages contain many Custom Resource Definitions and their controllers.
1415
1516
This is the Crossplane Provider package for [Equinix Metal](https://metal.equinix.com)
1617
infrastructure. The provider that is built from this repository can be installed
@@ -30,66 +31,97 @@ For getting started guides, installation, deployment, and administration, see th
3031

3132
## Installing Crossplane
3233

33-
For the most up to date, detailed, instructions, check [Crossplane's documentation](https://crossplane.io/docs/v0.13/getting-started/install-configure.html).
34+
For the most up to date, detailed, instructions, check [Crossplane's documentation](https://crossplane.io/docs/v1.2/getting-started/install-configure.html#install-crossplane).
3435

3536
The following instructions are provided for convenience.
3637

3738
```console
3839
kubectl create namespace crossplane-system
39-
helm repo add crossplane-alpha https://charts.crossplane.io/alpha
40-
helm install crossplane --namespace crossplane-system crossplane-alpha/crossplane
40+
helm repo add crossplane-stable https://charts.crossplane.io/stable
41+
helm repo update
42+
helm install crossplane --namespace crossplane-system crossplane-stable/crossplane --version 1.2.2
4143
```
4244

4345
### Install the Crossplane CLI
4446

47+
Fetch the CLI and follow the commands provided in the output:
48+
4549
```console
46-
curl -sL https://raw.githubusercontent.com/crossplane/crossplane/release-0.14/install.sh | sh
50+
$ curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh
51+
kubectl plugin downloaded successfully! Run the following commands to finish installing it:
52+
53+
sudo mv kubectl-crossplane $HOME/.local/bin
54+
kubectl crossplane --help
55+
56+
Visit https://crossplane.io to get started. 🚀
57+
Have a nice day! 👋
58+
```
59+
60+
```sh
61+
sudo mv kubectl-crossplane $HOME/.local/bin
4762
```
4863

4964
## Install the Equinix Metal Provider
5065

66+
For the most up to date version and install notes, see <https://cloud.upbound.io/registry/equinix/provider-equinix-metal>.
67+
5168
```console
52-
kubectl crossplane install provider equinix/crossplane-provider-equinix-metal
69+
kubectl crossplane install provider registry.upbound.io/equinix/provider-equinix-metal:v0.0.7
5370
```
5471

55-
The following commands will require your [Equinix Metal API key and a project ID](https://metal.equinix.com/developers/docs/). Entering your API key and project ID when prompted:
72+
After the package has been fetched and installed, you should see that the provider package is ready:
5673

5774
```console
58-
read -s -p "API Key: " APIKEY; echo
59-
read -p "Project ID: " PROJECT_ID; echo
75+
kubectl get provider -o wide
76+
NAME INSTALLED HEALTHY PACKAGE AGE
77+
equinix-provider-equinix-metal True True registry.upbound.io/equinix/provider-equinix-metal:v0.0.7 76m
6078
```
6179

6280
### Create a Provider Secret
6381

6482
Create a [Equinix Metal Project and a project level API key](https://metal.equinix.com/developers/docs/).
6583

66-
Create a Kubernetes secret with the API Key and Project ID.
84+
The following commands will require your [Equinix Metal API key and a project ID](https://metal.equinix.com/developers/docs/). Enter your API key and project ID when prompted:
85+
86+
```console
87+
read -s -p "API Key: " APIKEY; echo
88+
read -p "Project ID: " PROJECT_ID; echo
89+
```
90+
91+
_(The `read` command may need to be modified for shells other than bash.)_
92+
93+
Create a Kubernetes secret called `metal-creds` with the API Key and Project ID stored as JSON in a key called `credentials`.
6794

6895
```bash
69-
kubectl create -n crossplane-system secret generic packet-creds --from-file=key=<(echo '{"apiKey":"'$APIKEY'", "projectID":"'$PROJECT_ID'"}')
96+
kubectl create -n crossplane-system secret generic --from-file=credentials=<(echo '{"apiKey":"'$APIKEY'", "projectID":"'$PROJECT_ID'"}') metal-creds
7097
```
7198

72-
### Create a Provider record
7399

74-
Get the project id from the Equinix Metal Portal or using the Equinix Metal CLI (`packet project get`). With `PROJECT_ID` in your environemnt, run the command below:
100+
The secret name and key name are configurable. Whatever names you choose must match the settings in the `ProviderConfig` below.
101+
102+
### Create a Provider Config record
103+
104+
Get the project id from the Equinix Metal Portal or using the Equinix Metal CLI (`packet project get`). With `PROJECT_ID` in your environment, run the command below:
75105

76106
```bash
77107
cat << EOS | kubectl apply -f -
78108
apiVersion: metal.equinix.com/v1beta1
79109
kind: ProviderConfig
80110
metadata:
81-
name: default
111+
name: equinix-metal-provider
82112
spec:
83113
projectID: $PROJECT_ID
84114
credentials:
85115
source: Secret
86116
secretRef:
87117
namespace: crossplane-system
88-
name: packet-creds
89-
key: key
118+
name: metal-creds
119+
key: credentials
90120
EOS
91121
```
92122

123+
_TIP: If the `ProviderConfig` is given the special name "**default**", Equinix Metal Crossplane resources will choose this configuration making the `providerConfigRef` field optional._
124+
93125
## Provision an Equinix Metal Device
94126

95127
Save the following as `device.yaml`:
@@ -98,47 +130,58 @@ Save the following as `device.yaml`:
98130
apiVersion: server.metal.equinix.com/v1alpha2
99131
kind: Device
100132
metadata:
101-
name: devices
133+
name: crossplane-example
102134
spec:
103135
forProvider:
104-
hostname: crossplane
105-
plan: c1.small.x86
106-
facility: any
107-
operatingSystem: centos_7
136+
hostname: crossplane-example
137+
plan: c3.small.x86
138+
facility: sv15
139+
operatingSystem: ubuntu_20_04
108140
billingCycle: hourly
109141
hardware_reservation_id: next_available
110142
locked: false
143+
networkType: hybrid
111144
tags:
112145
- crossplane
113-
- development
146+
providerConfigRef:
147+
name: equinix-metal-provider
114148
writeConnectionSecretToRef:
115-
name: devices-creds
149+
name: crossplane-example
116150
namespace: crossplane-system
151+
reclaimPolicy: Delete
117152
```
118153
119-
```bash
154+
Create the resource:
155+
156+
```sh
120157
$ kubectl create -f device.yaml
121158
device.server.metal.equinix.com/devices created
122-
secret/devices-creds created
123159
```
124160

125-
To view the device in the cluster:
161+
To view the device and other Equinix Metal resources in the cluster:
126162

127163
```bash
128164
$ kubectl get equinix -o wide
129-
NAME PROJECT-ID AGE SECRET-NAME
130-
provider.metal.equinix.com/packet-provider 0ac84673-b679-40c1-9de9-8a8792675515 38m packet-creds
165+
kubectl get provider
166+
NAME INSTALLED HEALTHY PACKAGE AGE
167+
equinix-provider-equinix-metal True True registry.upbound.io/equinix/provider-equinix-metal:v0.0.7 73m
168+
169+
NAME READY SYNCED STATE ID HOSTNAME FACILITY IPV4 RECLAIM-POLICY AGE
170+
device.server.metal.equinix.com/crossplane-example True True active d81d643a-998f-4203-a667-7f9378481b1d crossplane-example sv15 139.178.68.111 53m
131171

132-
NAME READY SYNCED STATE ID HOSTNAME FACILITY IPV4 RECLAIM-POLICY AGE
133-
device.server.metal.equinix.com/devices True True active 1c73767a-e16a-485c-89b4-4b553e1458b3 crossplane sjc1 139.178.88.35 Delete 19m
172+
NAME AGE CONFIG-NAME RESOURCE-KIND RESOURCE-NAME
173+
providerconfigusage.metal.equinix.com/0a280921-1f3a-48ad-adb2-15ed8e6146f1 53m equinix-metal-provider Device crossplane-example
174+
175+
NAME AGE SECRET-NAME
176+
providerconfig.metal.equinix.com/equinix-metal-provider 69m
134177
```
135178

136179
SSH Connection credentials (including IP address, username, and password) can be found in the provider managed secret defined by `writeConnectionSecretToRef`.
137180

138181
**Caution** - Secret data is Base64 encoded, access to the namespace where this secret is stored offers `root` access to the provisioned device.
139182

140183
```bash
141-
$ kubectl get secret -n crossplane-system devices-creds -o jsonpath='{.data}'; echo
184+
$ kubectl get secret -n crossplane-system crossplane-example -o jsonpath='{.data}'; echo
142185
map[endpoint:MTM5LjE3OC44OC41Nw== password:cGFzc3dvcmQ== port:MjI= username:cm9vdA==]
143186
```
144187

@@ -147,7 +190,6 @@ To delete the device:
147190
```bash
148191
$ kubectl delete -f device.yaml
149192
device.server.metal.equinix.com/devices deleted
150-
secret/devices-creds deleted
151193
```
152194

153195
## Roadmap and Stability
@@ -156,6 +198,8 @@ This Crossplane provider is alpha quality and not intended for production use.
156198

157199
Equinix Metal devices, virtual networks, and ports can be managed through this provider, which provides basic integration. Advanced features like BGP, VPN, Volumes are not currently planned. If you are interested in these features, please let us know by [opening issues](#report-a-bug) and [reaching out](#contact).
158200

201+
See <https://github.com/packethost/crossplane-provider-equinix-metal/milestones> for project milestones.
202+
159203
## Contributing
160204

161205
crossplane-provider-equinix-metal is a community driven project and we welcome contributions. See the Crossplane [Contributing](https://github.com/crossplane/crossplane/blob/master/CONTRIBUTING.md) guidelines to get started.

cluster/examples/assignment.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: ports.metal.equinix.com/v1alpha1
3+
kind: Assignment
4+
metadata:
5+
name: crossplane-example-eth1-xp-vlan
6+
spec:
7+
forProvider:
8+
deviceIdRef:
9+
name: crossplane-example
10+
virtualNetworkIdRef:
11+
name: xp-vlan
12+
name: eth1
13+
providerConfigRef:
14+
name: equinix-metal-provider

cluster/examples/device.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1+
---
12
apiVersion: server.metal.equinix.com/v1alpha2
23
kind: Device
34
metadata:
4-
name: devicea
5-
namespace: app-project1-dev
5+
name: crossplane-example
66
spec:
77
forProvider:
8-
hostname: crossplane
9-
plan: c1.small.x86
10-
facility: any
11-
locked: false
12-
operatingSystem: centos_7
8+
hostname: crossplane-example
9+
plan: c3.small.x86
10+
facility: sv15
11+
operatingSystem: ubuntu_20_04
1312
billingCycle: hourly
1413
hardware_reservation_id: next_available
14+
locked: false
15+
networkType: hybrid
16+
tags:
17+
- crossplane
18+
providerConfigRef:
19+
name: equinix-metal-provider
1520
writeConnectionSecretToRef:
16-
name: devicea-conn
21+
name: crossplane-example
1722
namespace: crossplane-system
23+
reclaimPolicy: Delete

cluster/examples/provider.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22

3-
export BASE64ENCODED_PACKET_PROVIDER_CREDS=$(base64 credentials.txt | tr -d "\n")
4-
sed "s/BASE64ENCODED_PACKET_PROVIDER_CREDS/$BASE64ENCODED_PACKET_PROVIDER_CREDS/g" provider.yaml | kubectl create -f -
3+
export BASE64ENCODED_METAL_PROVIDER_CREDS=$(base64 credentials.txt | tr -d "\n")
4+
sed "s/BASE64ENCODED_METAL_PROVIDER_CREDS/$BASE64ENCODED_METAL_PROVIDER_CREDS/g" provider.yaml | kubectl create -f -

cluster/examples/provider.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ apiVersion: v1
33
kind: Secret
44
metadata:
55
name: example-provider-equinix-metal
6-
namespace: packet-infra-dev
6+
namespace: crossplane-system
77
type: Opaque
88
data:
9-
credentials: BASE64ENCODED_PACKET_PROVIDER_CREDS
9+
credentials: BASE64ENCODED_METAL_PROVIDER_CREDS
1010
---
1111
apiVersion: metal.equinix.com/v1beta1
1212
kind: ProviderConfig
1313
metadata:
14-
name: default
14+
name: equinix-metal-provider
1515
spec:
1616
credentialsSecretRef:
1717
name: example-provider-equinix-metal
18-
namespace: packet-infra-dev
18+
namespace: crossplane-system
1919
key: credentials
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: vlan.metal.equinix.com/v1alpha1
3+
kind: VirtualNetwork
4+
metadata:
5+
name: xp-vlan
6+
spec:
7+
forProvider:
8+
description: Example Crossplane provisioned VLAN
9+
facility: sv15
10+
providerConfigRef:
11+
name: equinix-metal-provider

0 commit comments

Comments
 (0)