Skip to content

Commit e89da26

Browse files
crossplane resources and readme
1 parent 4135419 commit e89da26

9 files changed

+213
-3
lines changed

kubernetes/crossplane/README.md

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,125 @@ kubectl get pods -n crossplane-system
4343
kubectl get deployments -n crossplane-system
4444
```
4545

46+
Once the pods are all running, we can see the `api-versions`
47+
48+
```
49+
kubectl api-versions | grep crossplane
50+
```
51+
52+
We can also see the new k8s objects that are installed with
53+
54+
```
55+
kubectl api-resources | grep crossplane
56+
```
57+
4658
## Providers
4759

48-
[Providers](https://docs.crossplane.io/latest/concepts/providers/)
60+
[Providers](https://docs.crossplane.io/latest/concepts/providers/) allow us to setup external providers that helps provision infrastructure for external services. </br>
61+
62+
For example, our crossplane cluster may have providers for deploying Azure, AWS, GCP or any other external infrastructure </br>
63+
64+
Furthermore, there is marketplace that hosts many providers, configurations and extensions for Crossplane called [Upbound](https://marketplace.upbound.io/providers)
65+
66+
67+
Install a Provider for a cloud provider Azure:
68+
69+
```
70+
kubectl apply -f kubernetes/crossplane/provider-azure.yaml
71+
```
72+
73+
Check our provider:
74+
75+
```
76+
kubectl get provider
77+
kubectl describe provider provider-family-azure
78+
```
79+
80+
## Provider Configuration
81+
82+
Once we have a provider setup, we can configure it using a `ProviderConfig` in Kubernetes </br>
83+
An impotrant configuration is to tell the Crossplane Provider how to authenticate with its external service. </br>
84+
85+
For example, when using an Azure Provider, you need an Azure Service Principal, and for AWS you may need a service account with AWS account id and key. </br>
86+
Each provider will have their own supported authentication methods. </br>
87+
88+
### Create Provider credentials
89+
90+
```
91+
SUBSCRIPTION_ID=<subscription-id>
92+
RESOURCE_GROUP=marcel-test
93+
94+
az account set -s $SUBSCRIPTION_ID
95+
az group create -n $RESOURCE_GROUP -l australiaeast
96+
az ad sp create-for-rbac --sdk-auth \
97+
-n marcel-test \
98+
--role Contributor \
99+
--scopes "/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP" > azure-credentials.json
100+
```
101+
102+
### Create Prpovider Kubernetes Secret
103+
104+
```
105+
kubectl create secret \
106+
generic azure-secret \
107+
-n crossplane-system \
108+
--from-file=creds=./azure-credentials.json
109+
```
110+
111+
### Deploy the Provider Configuration
112+
113+
```
114+
kubectl apply -f kubernetes/crossplane/providerconfig-azure.yaml
115+
```
116+
117+
### Create Provider Resources
118+
119+
```
120+
kubectl apply -f kubernetes/crossplane/resources/azure/resource-vnet.yaml
121+
122+
error: resource mapping not found for name: "marcel-test-vnet" namespace: "" from "kubernetes/crossplane/resources/azure/resource-vnet.yaml": no matches for kind "VirtualNetwork" in version "network.azure.upbound.io/v1beta1"
123+
ensure CRDs are installed first
124+
125+
```
126+
We see there is no CRD for Azure VNETs, that is because every type of resource in Azure is modularized into a separate provider, so we will need the networking provider first </br>
127+
128+
Install the Azure Network Provider:
129+
130+
```
131+
kubectl apply -f kubernetes/crossplane/provider-azure-network.yaml
132+
```
133+
134+
Retry the resource creation:
135+
136+
```
137+
kubectl apply -f kubernetes/crossplane/resources/azure/resource-vnet.yaml
138+
kubectl get virtualnetwork
139+
```
140+
141+
### Deploy a Virtual Network Subnet
142+
143+
```
144+
kubectl apply -f kubernetes/crossplane/resources/azure/resource-subnet.yaml
145+
kubectl get subnet
146+
```
147+
148+
### Deploy a Virtual Network Card
149+
150+
```
151+
kubectl apply -f kubernetes/crossplane/resources/azure/resource-networkcard.yaml
152+
kubectl get networkinterface
153+
```
154+
155+
### Deploy a Virtual Machine
156+
157+
Firstly need to add the compoute provider for Azure
158+
159+
```
160+
kubectl apply -f kubernetes/crossplane/provider-azure-compute.yaml
161+
```
162+
163+
Deploy a Virtual Machine:
164+
165+
```
166+
kubectl apply -f kubernetes/crossplane/resources/azure/resource-virtualmachine.yaml
167+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: pkg.crossplane.io/v1
2+
kind: Provider
3+
metadata:
4+
name: provider-azure-compute
5+
spec:
6+
package: xpkg.upbound.io/upbound/provider-azure-compute:v1.12.0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: pkg.crossplane.io/v1
2+
kind: Provider
3+
metadata:
4+
name: provider-azure-network
5+
spec:
6+
package: xpkg.upbound.io/upbound/provider-azure-network:v1.12.0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: pkg.crossplane.io/v1
22
kind: Provider
33
metadata:
4-
name: provider-azure-network
4+
name: provider-family-azure
55
spec:
6-
package: xpkg.crossplane.io/crossplane-contrib/provider-azure-network:v1.11.2
6+
package: xpkg.upbound.io/upbound/provider-family-azure:v1.12.0
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: azure.upbound.io/v1beta1
2+
metadata:
3+
name: default
4+
kind: ProviderConfig
5+
spec:
6+
credentials:
7+
source: Secret
8+
secretRef:
9+
namespace: crossplane-system
10+
name: azure-secret
11+
key: creds
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: network.azure.upbound.io/v1beta1
2+
kind: NetworkInterface
3+
metadata:
4+
labels:
5+
app: marcel-test
6+
name: marcel-test
7+
spec:
8+
forProvider:
9+
resourceGroupName: marcel-test
10+
ipConfiguration:
11+
- name: internal
12+
privateIpAddressAllocation: Dynamic
13+
subnetIdSelector:
14+
matchLabels:
15+
app: marcel-test
16+
location: "AustraliaEast"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: network.azure.upbound.io/v1beta2
2+
kind: Subnet
3+
metadata:
4+
labels:
5+
app: marcel-test
6+
name: marcel-test
7+
spec:
8+
forProvider:
9+
resourceGroupName: marcel-test
10+
addressPrefixes:
11+
- 10.0.2.0/24
12+
virtualNetworkNameSelector:
13+
matchLabels:
14+
app: marcel-test
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: compute.azure.upbound.io/v1beta2
2+
kind: LinuxVirtualMachine
3+
metadata:
4+
labels:
5+
app: marcel-test
6+
name: marcel-test
7+
spec:
8+
forProvider:
9+
resourceGroupName: marcel-test
10+
adminSshKey:
11+
- publicKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+wWK73dCr+jgQOAxNsHAnNNNMEMWOHYEccp6wJm2gotpr9katuF/ZAdou5AaW1C61slRkHRkpRRX9FA9CYBiitZgvCCz+3nWNN7l/Up54Zps/pHWGZLHNJZRYyAB6j5yVLMVHIHriY49d/GZTZVNB8GoJv9Gakwc/fuEZYYl4YDFiGMBP///TzlI4jhiJzjKnEvqPFki5p2ZRJqcbCiF4pJrxUQR/RXqVFQdbRLZgYfJ8xGB878RENq3yQ39d8dVOkq4edbkzwcUmwwwkYVPIoDGsYLaRHnG+To7FvMeyO7xDVQkMKzopTQV8AuKpyvpqu0a9pWOMaiCyDytO7GGN
12+
you@me.com
13+
username: adminuser
14+
adminUsername: adminuser
15+
location: "AustraliaEast"
16+
networkInterfaceIdsRefs:
17+
- name: marcel-test
18+
osDisk:
19+
caching: ReadWrite
20+
storageAccountType: Standard_LRS
21+
size: Standard_F2
22+
sourceImageReference:
23+
offer: UbuntuServer
24+
publisher: Canonical
25+
sku: 16.04-LTS
26+
version: latest
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: network.azure.upbound.io/v1beta1
2+
kind: VirtualNetwork
3+
metadata:
4+
name: marcel-test-vnet
5+
labels:
6+
app: marcel-test
7+
spec:
8+
forProvider:
9+
addressSpace:
10+
- 10.0.0.0/16
11+
location: "AustraliaEast"
12+
resourceGroupName: marcel-test

0 commit comments

Comments
 (0)