Skip to content

Commit afbd9e6

Browse files
maciaszczykmzreigzfloreksdavidspekmichaeljguarino
authored
feat: Use CAPI for provisioning clusters (#424)
* Bump cluster-api-migration * bump migrator * Bump cluster-api-migration * bump migrator * bump migrator * bump migrator * Update GCP migration config * optimize imports * Remove --cluster-api flag * update google bootstrap flags * Fix deploy logic * bump migrator * update destroy bootstrap flags for google provider * Check if cluster exists * update destroy steps * Fix deploy * Add logging * Add missing new line * Fix log types * Add client ID and secret to init survey * remove cluster resources during destroy * Fix wait command * Remove plural clusters watch command * Run go mod tidy * Fix unit tests * Print step numbers for bootstrap and migration * Remove plural cluster watch command and some unused code * Remove build step and update descriptions for CAPI deploy * Refactor deploy and migration steps * Refactor destroy steps * Add destroy logs * Refactor * Move CAPI related logic from cmd to pkg * Extract common code * Move checks * Fix minor import issue * Cleanup * Remove unused flag Remove duplicated command * Minor improvements * Add TODO * add post install step * Update cluster readiness check * Fix merge conflicts * Update migration configuration for gcp * Export execute steps function * Refactor * Refactor migration * Add tests for common functions * Improve GCP preflight checks * Add tests for migration functions * Update messaging * add kind provider * Raise destroy timeout * Refactor cilium.go * Fix resource group and storage account name validation * Add command to check if chart is installed * save kubeconfig * add kind configuration * fix kind configuration * fix docker destroy * normilize kind * update e2e test * update github action * bump kind action * create bootstrap namespace * create bootstrap namespace * add extra debug * do not run migrate when cluster already migrated * read sa email from credentials file * add vendor dir to gitignore * fix import cycle * add PLURAL_DISABLE_MP_TABLE_VIEW env for machine pools view * remove bootstrap operator dependencies * cilium update * refactor * split e2e tests * change name * Refactor e2e workflows * distinguish between regular and cluster api * distinguish between regular and cluster api - fix * distinguish between regular and cluster api - improvement * distinguish between regular and cluster api - improvement * distinguish between regular and cluster api - improvement * add e2e test for cluster api * enable list view for destroy * add e2e test to check installed packages * fix linter * Update github.com/gin-gonic/gin to avoid CVE * Bump dependencies * Read Go version from go.mod in CI * Bump dependencies * improve error handling for deoploy/destroy cluster * e2e update machine pool * Refactor storage account code * Fixes * Fix unit tests * Fix kind delete * remove role permissions check for gcp SA and use local CLI ADC for migration and bootstraping * fetch AvailabilityZones * fix unit test * Use Microsoft Graph SDK to create service principal and get client ID and secret * set bootstrapMode flag for gcp during the bootstrap phase * fix fetching zones * Add proper role assignment to Azure service principal * fix execute not showing error and add workaround for tf value templating issue * Minor improvements * read gcp credentials from adc file * Fix client ID * change migrate to run deploy at the end and run gcp in bootstrapMode during migrate * update gcp permissions check * set azure bootstrap mode flag Signed-off-by: David van der Spek <[email protected]> * Add commit flag at the end of running migrate (#436) It's very likely a large number of users will forget to manage their git, we should just remove that possibility w/ this. * do not use bootstrap mode for the gcp migration * improve gcp permissions check messaging * Fix typo * Enable OIDC issuer for Azure clusters * add some todo comments Signed-off-by: David van der Spek <[email protected]> * Create temporary service principal with password during deploy and destroy * Refactor * e2e update machine pool version * Fix destroy * update bootstrap step building logic * add plural build-values REPO * init bubbletea tui * revert bootstrap step changes * Resolve Helm issue * Extract methods from bootstrap steps * Fix destroy * Modify aws auth configmap manually to solve migration chicken-egg (#437) * Modify aws auth configmap manually to solve migration chicken-egg This allows us to reusably modify the aws-auth configmap for eks from the client which should help resolve some migrration-time issues * add to migrate steps * Add secret list and create funcs * Add kube initializer with context * add feature flag for CAPI stuff * fix build * Add kube initializer with context * set aws credentials * cleanup build values command * use dynamic credentials for GCP without storing them on the repo * lint fix * Refactor * Rename file * allow overriding enable field of helm modules * Fix var name * Simplify migration * Restore uninstall azure-identity package step * update gcp permissions check name * fix nil pointer error when listing uninstalled package * improve fetching AZs * bump migrator version (#440) Signed-off-by: David van der Spek <[email protected]> * fix gcp provider name * remove credentials * Properly normalize Google -> GCP provider name and add migration step to update google provider name to gcp * update go.sum * make genmock * Fix executor println (#443) This was always saying "actionName <app>" instead of the passed action name. * bump migrator * small refactor * Bump migrator version * fix null replacment * Deprecate values.yaml migration * bump migrator * Fix Azure destroy after migration * Refactor step filtering * Fix Azure identity bug * add posthog feature call timeout and fix caching * cleanup some steps * Switch google to gcp during init * Update messaging for GCP * bump migrator * update go.sum * fix linters * ci: ensure docker buildx removes the running nodes (#448) Signed-off-by: David van der Spek <[email protected]> * Add semver validation for required bootstrap tf/helm modules on migration (#445) There are now some requirements for performing a migration tied to our helm/tf. This will at least guarantee they're installed at migrate time. * remove default values from migration values.yaml * go mod tidy * update AZs during migration * disable external-dns and plural-certmanager-webhook * Do not delete bootstrap cluster on failed deploy * fix disabling plural-certmanager-webhook Signed-off-by: David van der Spek <[email protected]> * also disable external dns on gcp and azure Signed-off-by: David van der Spek <[email protected]> * Update step handling * Add retry mechanism * Fix step numbering * Fix unit tests * Further improvements * Use map to store provider tags * add move state backup and restore to capi deploy * Further improvements * Fix OIDC issuer step * Fix typo * add initial step confirm support * move capi backup to .plural dir and add multi-cluster backup support * Remove tui package * add conditional recovery steps when cluster issues are detected --------- Signed-off-by: David van der Spek <[email protected]> Co-authored-by: Lukasz Zajaczkowski <[email protected]> Co-authored-by: Sebastian Florek <[email protected]> Co-authored-by: David van der Spek <[email protected]> Co-authored-by: michaeljguarino <[email protected]> Co-authored-by: David van der Spek <[email protected]>
1 parent 4bd34b5 commit afbd9e6

Some content is hidden

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

96 files changed

+6564
-872
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
fetch-depth: 0
2929
- uses: actions/setup-go@v3
3030
with:
31-
go-version: 1.18
31+
go-version-file: go.mod
3232
- uses: github/codeql-action/init@v2
3333
with:
3434
languages: ${{ matrix.language }}

.github/workflows/e2e.yaml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,53 @@ on:
44
branches:
55
- main
66
jobs:
7+
create-cluster-capi:
8+
name: Create cluster with Cluster API
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
- name: Create kind cluster
14+
uses: helm/[email protected]
15+
with:
16+
install_only: true
17+
- run: |
18+
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
19+
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
20+
sudo apt-get update
21+
sudo apt-get install -y terraform
22+
- run: |
23+
GOBIN="$HOME"/bin make build-cli
24+
chmod 755 plural.o
25+
mv plural.o /usr/local/bin/plural
26+
- run: hack/e2e/kind-install-for-capd.sh
27+
- run: hack/e2e/setup-plural.sh
28+
env:
29+
CLI_E2E_CONF: ${{ secrets.CLI_E2E_CONF }}
30+
CLI_E2E_IDENTITY_FILE: ${{ secrets.CLI_E2E_IDENTITY_FILE }}
31+
CLI_E2E_KEY_FILE: ${{ secrets.CLI_E2E_KEY_FILE }}
32+
CLI_E2E_PUBLIC_KEY: ${{ secrets.CLI_E2E_PUBLIC_KEY }}
33+
CLI_E2E_PRIVATE_KEY: ${{ secrets.CLI_E2E_PRIVATE_KEY }}
34+
CLI_E2E_SHARING_PRIVATE_KEY: ${{ secrets.CLI_E2E_SHARING_PRIVATE_KEY }}
35+
CLI_E2E_SHARING_PUBLIC_KEY: ${{ secrets.CLI_E2E_SHARING_PUBLIC_KEY }}
36+
USE_CLUSTER_API: true
37+
- run: go test -v -race ./pkg/test/e2eclusterapi/... -tags="e2e"
38+
- run: |
39+
cd $HOME/test
40+
plural destroy --force --all --commit=""
41+
env:
42+
PLURAL_DESTROY_CONFIRM: true
43+
PLURAL_DESTROY_AFFIRM_UNINSTALL_APPS: true
44+
PLURAL_DISABLE_MP_TABLE_VIEW: true
745
create-cluster:
46+
if: false
47+
name: Create cluster
848
runs-on: ubuntu-latest
949
steps:
1050
- name: Checkout
1151
uses: actions/checkout@v3
12-
- name: Create k8s Kind Cluster
13-
uses: helm/kind-action@v1.5.0
52+
- name: Create kind cluster
53+
uses: helm/kind-action@v1.8.0
1454
with:
1555
install_only: true
1656
- run: |
@@ -31,10 +71,12 @@ jobs:
3171
CLI_E2E_PRIVATE_KEY: ${{ secrets.CLI_E2E_PRIVATE_KEY }}
3272
CLI_E2E_SHARING_PRIVATE_KEY: ${{ secrets.CLI_E2E_SHARING_PRIVATE_KEY }}
3373
CLI_E2E_SHARING_PUBLIC_KEY: ${{ secrets.CLI_E2E_SHARING_PUBLIC_KEY }}
74+
INSTALL_APP: console
75+
INSTALL_RECIPE: console-kind
3476
- run: go test -v -race ./pkg/test/e2e/... -tags="e2e"
3577
- run: |
3678
cd $HOME/test
3779
plural destroy --force --all --commit=""
3880
env:
3981
PLURAL_DESTROY_CONFIRM: true
40-
PLURAL_DESTROY_AFFIRM_UNINSTALL_APPS: true
82+
PLURAL_DESTROY_AFFIRM_UNINSTALL_APPS: true

.gitignore

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
# Binaries for programs and plugins
1+
# IDE files
2+
.idea/
3+
.vscode/
4+
5+
# Testing files
6+
context.yaml
7+
workspace.yaml
8+
9+
# Build files and binaries
10+
dist/
11+
build/
212
*.exe
313
*.exe~
414
*.dll
515
*.so
616
*.o
717
*.dylib
18+
__debug_bin
819

920
# Test binary, built with `go test -c`
1021
*.test
@@ -13,15 +24,6 @@
1324
*.out
1425
forge*.o
1526
plural*.o
16-
# Dependency directories (remove the comment below to include it)
17-
# vendor/
1827

19-
# IDE dirs
20-
.idea/
21-
22-
dist/
23-
build/
24-
25-
# Testing files
26-
context.yaml
27-
workspace.yaml
28+
# Vendored dependencies
29+
vendor/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ git-push:
3737
git push
3838

3939
.PHONY: install
40-
install: build-cli-ui
41-
mv $(OUTFILE) ~/bin/plural
40+
install:
41+
go install -ldflags '$(LDFLAGS)' .
4242

4343
.PHONY: build-cli
4444
build-cli: ## Build a CLI binary for the host architecture without embedded UI

cmd/plural/api.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package plural
22

33
import (
4-
"github.com/pluralsh/plural/pkg/api"
5-
"github.com/pluralsh/plural/pkg/utils"
64
"github.com/pluralsh/polly/algorithms"
75
"github.com/urfave/cli"
6+
7+
"github.com/pluralsh/plural/pkg/api"
8+
"github.com/pluralsh/plural/pkg/utils"
89
)
910

1011
func (p *Plural) apiCommands() []cli.Command {
@@ -111,7 +112,7 @@ func (p *Plural) handleCharts(c *cli.Context) error {
111112

112113
func (p *Plural) handleTerraforma(c *cli.Context) error {
113114
p.InitPluralClient()
114-
tfs, err := p.GetTerraforma(c.Args().First())
115+
tfs, err := p.GetTerraform(c.Args().First())
115116
if err != nil {
116117
return api.GetErrorResponse(err, "GetTerraforma")
117118
}

0 commit comments

Comments
 (0)