Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

Commit f9a3a45

Browse files
committed
Initial commit
Signed-off-by: Adam Fowler <adam@adamfowler.org>
1 parent 9d5e5da commit f9a3a45

File tree

44 files changed

+5173
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+5173
-9
lines changed

.gitignore

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
# Ignore everything in this directory
2-
*
3-
# Except this file
4-
!.gitignore
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
/bin
8+
9+
# Test binary, built with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool, specifically when used with LiteIDE
13+
*.out
14+
15+
# Dependency directories (remove the comment below to include it)
16+
# vendor/
17+
18+
# Terraform example
19+
.terraform
20+
.terraform.lock.hcl
21+
terraform.tfstate
22+
terraform.tfstate.backup
23+
.terraform.tfstate.lock.info
24+
.terraform.tfstate.swp
25+
26+
*~

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Contributing to terraform-provider-namespace-management
22

3+
TODO replace with CLA (As it's Apache 2.0)
4+
35
The terraform-provider-namespace-management project team welcomes contributions from the community. Before you start working with terraform-provider-namespace-management, please
46
read our [Developer Certificate of Origin](https://cla.vmware.com/dco). All contributions to this repository must be
57
signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
TEST?=$$(go list ./... | grep -v 'vendor')
2+
HOSTNAME=vmware.com
3+
NAMESPACE=vcenter
4+
NAME=namespace-management
5+
BINARY=terraform-provider-${NAME}
6+
VERSION=0.1
7+
OS_ARCH=darwin_amd64
8+
9+
default: install
10+
11+
build:
12+
go build -o ${BINARY}
13+
14+
release:
15+
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
16+
GOOS=darwin GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_darwin_arm64
17+
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386
18+
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64
19+
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm
20+
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386
21+
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64
22+
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm
23+
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386
24+
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64
25+
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64
26+
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386
27+
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64
28+
29+
install: build
30+
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
31+
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
32+
33+
test:
34+
go test -i $(TEST) || exit 1
35+
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
36+
37+
testacc:
38+
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

README.md

Lines changed: 162 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,168 @@
1-
# terraform-provider-namespace-management
1+
# Namespace Management Terraform provider
22

3-
## Overview
3+
This Terraform Provider enables control of vSphere Workload Management.
4+
This includes enabling or disabling workload management
5+
(effectively creating, and destroying, Tanzu Supervisor Clusters),
6+
and enabling or disabling supervisor cluster services.
7+
8+
The project is called namespace-management rather than tanzu-supervisor
9+
to be consistent with the vSphere API name which it wraps.
10+
11+
Note that Tanzu Workload Clusters should be requested by sending YAML
12+
configuration via kubectl to the appropriate Supervisor Cluster's
13+
vSphere namespace. There is no internal vSphere REST API for this by design.
14+
(This is internalised in CAPV - Cluster API for vSphere).
15+
16+
Likewise, creating the underlying infrastructure in vSphere can be
17+
accomplished by using the
18+
[HashiCorp vSphere provider](https://registry.terraform.io/providers/hashicorp/vsphere)
19+
and the [Avi Terraform Provider]().
20+
An example of these being used alongside our Workload Management
21+
Terraform provider is provided in the
22+
examples/full_esxi_tanzu_cluster sample.
23+
24+
## Pre initial release sprints
25+
26+
- Alpha 1
27+
- Single Avi controller instance, Avi Essentials configuration only, v21.1.2
28+
- vDS networking 7.0u2 and 7.0u3 support for vCenter
29+
- Works with latest photon build for TKGS (see concourse/combinations/README.md)
30+
- Tested against h2o.vmware.com and my own homelab nested esxi environment
31+
- No automated CI/CD testing
32+
- Manual uploading of OVAs and manual Content Library creation
33+
- Add all necessary repo files (Update CLA from DCO, CONTRIBUTING changes for this too)
34+
- Support manual build only (Provider not yet added to Terraform registry)
35+
- Govmomi bug fixes and enhancements contributed back to project
36+
- REQUEST REPO BE MADE PUBLIC
37+
- Alpha 2
38+
- Functional validation tests post cluster creation (Node up, node reachable)
39+
- Overarching Concourse tests for develop branch
40+
- Concourse loads environment combinations and runs multiple env pipelines in order using Terraform
41+
- Support n-2 photon versions
42+
- Automate testing on h20 (7.0u2) and homelab (7.0u3) using Concourse remote workers
43+
- This is a total of 6 combinations
44+
- Include initial vDS creation
45+
- Include file upload from staging to datastore
46+
- Include content library creation and uploading of TKR releases
47+
- Produce test report summary files for develop branch
48+
- Project introduction video
49+
- Support manual build only (Provider not yet added to Terraform registry)
50+
- Beta 1
51+
- Beta builds submitted automatically to Terraform registry on tag and release (main branch)
52+
- Full sample documentation
53+
- Include support for TkgServiceConfiguration customisation
54+
- Include support for Custom ingress and egress CIDR ranges, CA certs
55+
- Include restriction of Certs used for EC P-256
56+
- Multi-node Avi controller support
57+
- Avi Enterprise support (including license key upload)
58+
- Add more version combinations
59+
- n-2 Avi version support
60+
- This is a total of 12 combinations
61+
- Bootstrap Harbor VM support
62+
- Helm Harbor services cluster support and sample
63+
- Node/pod communication check tests (VMs, Pods)
64+
- More detailed Concourse build success reports
65+
- Beta 2
66+
- Add more version and environment combinations
67+
- Include basic Workload Cluster creation for photon and ubuntu TKR at n-2 (Only 2 supported currently)
68+
- Latest NSX-T support with own load balancer
69+
- This is 48 combinations in total
70+
- NSX-T support intro video
71+
- Built in Harbor support
72+
- Support for shared and standalone prometheus, grafana
73+
- Initial full release
74+
- Add new environment and versions
75+
- NSX-T n-2 version support
76+
- NSX-T support with Avi load balancer
77+
- Latest ESXi/vSphere version tested (currently 7.0u3d)
78+
- n-2 tests for Avi Load Balancer, Avi Terraform Plugin (Matched to Avi), NSX-T and NSX-T Terraform Plugin (Matched to NSX-T)
79+
- This is 576 combinations
80+
- Full suite of tests (main and develop branches) with all latest minor releases of k8s TKRs
81+
- Tanzu Standard on top of vSphere for Tanzu, with restricted psp/opa
82+
- Istio with ingress, egress, istio-cni, minimum extra permissions (just the CNI pod)
83+
- Kiali support for istio configuration validation/manual checking
84+
- Full release documentation
85+
- Launch video
86+
87+
88+
## Status (PRIOR TO INITIAL PUBLIC RELEASE ONLY, THEN REMOVED FROM HERE)
89+
90+
- data_source_clusters
91+
- clustersRead()
92+
- lists clusters with id, name, k8s status, config status
93+
- Uses GET /api/vcenter/namespace-management/clusters
94+
- Working, see examples/03_basic_list/clusters/main.tf
95+
- Returns { clusters: [ {id: "domain-c1005", name:"Cluster01", kubernetes_status:"READY", config_status:"RUNNING"}, ... ] }
96+
- data_source_cluster
97+
- clusterRead()
98+
- Given a cluster NAME (NOT id) like 'Cluster01' returns the cluster's Tanzu Supervisor Cluster summary
99+
- Uses GET /api/vcenter/namespace-management/clusters
100+
- Summary includes (only) id, name, kubernetes_status, config_status
101+
- Working, see see examples/02_basic_read/clusters/main.tf
102+
- Returns {id: "domain-c1005", name:"Cluster01", kubernetes_status:"READY", config_status:"RUNNING"}
103+
- resource_cluster
104+
- clusterCreate()
105+
- Given a vSphere cluster ID (NOT name) like 'domain-c1005', enables workload management
106+
- Uses POST /api/vcenter/namespace-management/clusters/{cluster}?action=enable
107+
- Implemented, untested, see examples/01_basic_create/clusters/main.tf
108+
- Uses hardcoded cluster enable spec data today
109+
- Limited to NSX-T today rather than full information due to missing govmomi features: https://github.com/vmware/govmomi/issues/2860
110+
- Warning: Due to the above, the workload cluster NTP source(s) will not be set, which will cause your workload clusters to not spin up successfully until you manually add this configuration element via vCenter
111+
- clusterRead()
112+
- Given a cluster NAME (NOT id) like 'Cluster01' returns the cluster's Tanzu Supervisor Cluster summary
113+
- Uses List method as data_clusters clusterRead today
114+
- Working, see see examples/02_basic_read/clusters/main.tf
115+
- Limited to cluster summary today rather than full information due to missing govmomi feature: https://github.com/vmware/govmomi/issues/2860
116+
- clusterUpdate()
117+
- Given a vSphere cluster ID (NOT name) like 'domain-c1005', replaces the current cluster enable spec with a new full spec
118+
- Not implemented today
119+
- clusterDelete()
120+
- Given a vSphere cluster ID (NOT name) like 'domain-c1005', disables workload management
121+
- Doesn't actually delete the vSphere cluster, just the Tanzu Supervisor Cluster
122+
- Not implemented
4123

5124
## Try it out
6125

7126
### Prerequisites
8127

9-
* Prereq 1
10-
* Prereq 2
11-
* Prereq 3
128+
* You must have Terraform installed on your system
129+
* You must have a Go runtime installed with corresponding build tools
130+
* You must have a vSphere 7.0 update 2 (7.0.2) system configured with a vCenter and at least two hosts (ideally 3 or more)
131+
132+
## Building the provider
133+
134+
Run the following command to build the provider
135+
136+
```shell
137+
go build -o terraform-provider-namespace-management
138+
```
139+
140+
## Test sample configuration
141+
142+
First, build and install the provider.
143+
144+
```shell
145+
make install
146+
```
147+
148+
Download the simulator from here:
149+
150+
TODO REWORK THIS SECTION TO NOT USE THE SIMULATOR
151+
152+
Now unpack and run the VMware simulator
153+
```shell
154+
cat ~/Downloads/vcsim_PLATFORM_ARCH.tar.gz | sudo tar -C /usr/local/bin -xzvf - vcsim
155+
vcsim &
156+
```
157+
158+
This will report `export GOVC_URL=https://user:pass@127.0.0.1:8989/sdk GOVC_SIM_PID=69867` when running
159+
160+
Then, run the following command to initialize the workspace and apply the sample configuration.
161+
162+
```shell
163+
cd examples/SOME_EXAMPLE
164+
terraform init && terraform apply
165+
```
12166

13167
### Build & Run
14168

@@ -20,10 +174,13 @@
20174

21175
## Contributing
22176

177+
TODO REPLACE WITH CLA (As it's Apache 2)
178+
23179
The terraform-provider-namespace-management project team welcomes contributions from the community. Before you start working with terraform-provider-namespace-management, please
24180
read our [Developer Certificate of Origin](https://cla.vmware.com/dco). All contributions to this repository must be
25181
signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on
26182
as an open-source patch. For more detailed information, refer to [CONTRIBUTING.md](CONTRIBUTING.md).
27183

28184
## License
29185

186+
This project is licensed under the terms of the Apache-2.0 license and is Copyright VMware, Inc. 2022. See the LICENSE file for full details.

concourse/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Concourse automation
2+
3+
Due to the nature of complex multi-host testing it is not possible
4+
to use standard GitHub CI automation to test everything within
5+
this project's repositories.
6+
7+
It is insufficient to test just the provider code or to
8+
use the vcsim software to validate this terraform module.
9+
This is because vcsim's code is created to precisely match
10+
the vCenter API Go wrapper in the same repository - so it is
11+
much more likely any bug in the Go API wrapper has been duplicated
12+
in the vcsim software that was created for it.
13+
14+
There is also the problem of regressions. As new software comes
15+
out we need to run tests against this new infrastructure.
16+
GitHub CI only tests the code at the point when code is created
17+
or a Pull Request submitted. So we need another way to monitor
18+
and detect upstream software changes - as they happen - and test
19+
various supported combinations of VMware software against these
20+
Terraform modules. We also need to do this against multiple
21+
platforms many of which are on different networks.
22+
23+
This is where Concourse, the generic thing do-er, comes in.
24+
Concourse is a Free and Open Source Software (FOSS) project
25+
that allows for a declarative event-driven approach to testing
26+
software as new builds are released. Concourse proactively
27+
monitors a set of dependencies and if they change will kick
28+
off a build.
29+
30+
This folder holds the tests and supported platform combinations
31+
and configurations for both the development branch (/concourse/develop)
32+
and main branch (/concourse/main) code repositories.
33+
34+
When changes occur, the Concourse runtime on multiple servers will
35+
initiate, perform a FRESH infra rollout and automate any additional
36+
practical checks and tests. If any issues are found they will be
37+
summarised and added to a GitHub Issue automatically.
38+
39+
## Contents
40+
41+
* main folder - tests that run against the current release and prior releases
42+
* develop folder - tests that run against the current develop branch
43+
* FOLDER/pipeline-*.yaml - A single pipeline in Concourse
44+
* FOLDER/settings-*.yaml - Settings that automated CI may update
45+
* combinations folder - One file per supported product combination
46+
47+
### Common question: Shouldn't the develop tests live in the develop branch?
48+
49+
No. The develop branch is for 'changes undergoing testing' Thus the develop
50+
branch of the main folder is 'changes we're trying out to tests we want
51+
to apply to current and previous releases' and the develop branch of the
52+
develop folder is 'changes we're trying out to the tests of the things
53+
we're adding/building in the develop branch'. So whilst the naming
54+
is similar, the reasoning for using BOTH folder names and branches is sound.
55+
56+
## How this works
57+
58+
We maintain a set of settings in the settings-combinations.yaml file. This
59+
uses the [experimental instance groups feature](https://concourse-ci.org/instanced-pipelines.html)
60+
of Concourse to instantiate a pipeline per target test environment.
61+
This means a single pipeline definition is instantiated for each version combination
62+
and settings, enabling us to test upcoming versions we've not specifically
63+
coded for upon release.
64+
65+
## TODO items
66+
67+
In order of decreasing value to this project and its users:-
68+
69+
Immediate / Proof of Concept:-
70+
71+
* As a new develop merge occurs, run the real tests against a new rollout on Adam's Homelab on 7.0.3 with vDS and Avi
72+
73+
Before v1.0 release:-
74+
75+
* Support for NSX-T deployments
76+
* Support for NSX-T with Avi deployments
77+
* Most secure by default (See ../security/README.md for details) settings and tests (poor man's pen testing)
78+
* Automation for current supported (Beyond Sep 2022) version combinations of vSphere with Tanzu (See combinations/ for details)
79+
80+
Futures:-
81+
82+
* Help other teams deliver the same for TKGm (Multicloud) and TKGI (integrated) on different cloud platforms

0 commit comments

Comments
 (0)