weaveworks / weave-gitops-enterprise

This repo provides the enterprise level features for the weave-gitops product, including CAPI cluster creation and team workspaces.
https://docs.gitops.weave.works/
Apache License 2.0
160 stars 30 forks source link

Redundant checks when bootstrap #3754

Open gecube opened 9 months ago

gecube commented 9 months ago

Hello!

I am installing the gitops-ee tooling as I want to play around with it on one of EKS clusters, that I use for managing infra. I am expecting that I will be able to prepare manifests for gitops platform and put them into gitrepo. It is another issue, right now I want to focus that bootstrap command make extra checks.

First try was to run it without any cluster access:

components % gitops bootstrap --export
► creating client to cluster
✔ created client to cluster: https://kubernetes.docker.internal:6443
◎ checking flux
► verifying flux installation
✗ flux installed error: ► checking prerequisites
✗ flux 2.2.2 <2.2.3 (new CLI version is available, please upgrade)
✗ Kubernetes API call failed: Get "https://kubernetes.docker.internal:6443/version": dial tcp 127.0.0.1:6443: connect: connection refused
► checking version in cluster
✗ checking failed: failed to get API group resources: unable to retrieve the complete list of server APIs: apiextensions.k8s.io/v1: Get "https://kubernetes.docker.internal:6443/apis/apiextensions.k8s.io/v1": dial tcp 127.0.0.1:6443: connect: connection refused
► checking controllers
► checking crds
✗ check failed
. flux is not bootstrapped in 'flux-system' namespace: more info https://fluxcd.io/flux/installation
? do you want to bootstrap flux using the generic way? [y/N] n█
Error: cannot execute bootstrap: error on step bootstrap flux: cannot execute 'bootstrap flux': flux error: flux is not bootstrapped, please bootstrap Flux in 'flux-system' namespace: more info https://fluxcd.io/flux/installation

Then I understood that I need to point to particular cluster where gitops platform would be deployed, so I login in teleport and selected the proper context:

components % gitops bootstrap --export
► creating client to cluster
✔ created client to cluster: https://teleport.*****:3026
◎ checking flux
► verifying flux installation
✗ flux installed error: ► checking prerequisites
✗ flux 2.2.2 <2.2.3 (new CLI version is available, please upgrade)
✗ Kubernetes version v1.25.16-eks-77b1e4e does not match >=1.26.0-0
► checking version in cluster
✔ distribution: flux-v2.1.2
✔ bootstrapped: true
► checking controllers
✔ helm-controller: deployment ready
► ghcr.io/fluxcd/helm-controller:v0.36.2
✔ image-automation-controller: deployment ready
► ghcr.io/fluxcd/image-automation-controller:v0.36.1
✔ image-reflector-controller: deployment ready
► ghcr.io/fluxcd/image-reflector-controller:v0.30.0
✔ kustomize-controller: deployment ready
► ghcr.io/fluxcd/kustomize-controller:v1.1.1
✔ notification-controller: deployment ready
► ghcr.io/fluxcd/notification-controller:v1.1.0
✔ source-controller: deployment ready
► ghcr.io/fluxcd/source-controller:v1.1.2
► checking crds
✔ alerts.notification.toolkit.fluxcd.io/v1beta2
✔ buckets.source.toolkit.fluxcd.io/v1beta2
✔ gitrepositories.source.toolkit.fluxcd.io/v1
✔ helmcharts.source.toolkit.fluxcd.io/v1beta2
✔ helmreleases.helm.toolkit.fluxcd.io/v2beta1
✔ helmrepositories.source.toolkit.fluxcd.io/v1beta2
✔ imagepolicies.image.toolkit.fluxcd.io/v1beta2
✔ imagerepositories.image.toolkit.fluxcd.io/v1beta2
✔ imageupdateautomations.image.toolkit.fluxcd.io/v1beta1
✔ kustomizations.kustomize.toolkit.fluxcd.io/v1
✔ ocirepositories.source.toolkit.fluxcd.io/v1beta2
✔ providers.notification.toolkit.fluxcd.io/v1beta2
✔ receivers.notification.toolkit.fluxcd.io/v1
✗ check failed
. flux is not bootstrapped in 'flux-system' namespace: more info https://fluxcd.io/flux/installation
◎ bootstrap flux
✗ do you want to bootstrap flux using the generic way: 
Error: cannot execute bootstrap: error on step bootstrap flux: cannot execute 'bootstrap flux': flux error: flux is not bootstrapped, please bootstrap Flux in 'flux-system' namespace: more info https://fluxcd.io/flux/installation
components % flux

Gitops tooling explained to me that I need to bump flux version, O.K., no problems. I installed new flux version and prepared a manifests. Then applied them to cluster.

george@ZMWSPAPNTYW124XX2 weave-enterprise % gitops bootstrap --export
► creating client to cluster
✔ created client to cluster: https://teleport.private.zodiamarkets.xyz:3026
◎ checking flux
► verifying flux installation
✗ flux installed error: ► checking prerequisites
✗ Kubernetes version v1.25.16-eks-77b1e4e does not match >=1.26.0-0
► checking version in cluster
✔ distribution: flux-v2.2.3
✔ bootstrapped: true
► checking controllers
✔ helm-controller: deployment ready
► ghcr.io/fluxcd/helm-controller:v0.37.4
✔ image-automation-controller: deployment ready
► ghcr.io/fluxcd/image-automation-controller:v0.37.1
✔ image-reflector-controller: deployment ready
► ghcr.io/fluxcd/image-reflector-controller:v0.31.2
✔ kustomize-controller: deployment ready
► ghcr.io/fluxcd/kustomize-controller:v1.2.2
✔ notification-controller: deployment ready
► ghcr.io/fluxcd/notification-controller:v1.2.4
✔ source-controller: deployment ready
► ghcr.io/fluxcd/source-controller:v1.2.4
► checking crds
✔ alerts.notification.toolkit.fluxcd.io/v1beta3
✔ buckets.source.toolkit.fluxcd.io/v1beta2
✔ gitrepositories.source.toolkit.fluxcd.io/v1
✔ helmcharts.source.toolkit.fluxcd.io/v1beta2
✔ helmreleases.helm.toolkit.fluxcd.io/v2beta2
✔ helmrepositories.source.toolkit.fluxcd.io/v1beta2
✔ imagepolicies.image.toolkit.fluxcd.io/v1beta2
✔ imagerepositories.image.toolkit.fluxcd.io/v1beta2
✔ imageupdateautomations.image.toolkit.fluxcd.io/v1beta1
✔ kustomizations.kustomize.toolkit.fluxcd.io/v1
✔ ocirepositories.source.toolkit.fluxcd.io/v1beta2
✔ providers.notification.toolkit.fluxcd.io/v1beta3
✔ receivers.notification.toolkit.fluxcd.io/v1
✗ check failed
. flux is not bootstrapped in 'flux-system' namespace: more info https://fluxcd.io/flux/installation
◎ bootstrap flux
? do you want to bootstrap flux using the generic way? [y/N] █
Error: cannot execute bootstrap: error on step bootstrap flux: cannot execute 'bootstrap flux': flux error: flux is not bootstrapped, please bootstrap Flux in 'flux-system' namespace: more info https://fluxcd.io/flux/installation

Now I am still experiencing error that flux is not installed, but it is. Probably the issue is the incorrect and incompatible (srsly?) k8s version:

✗ Kubernetes version v1.25.16-eks-77b1e4e does not match >=1.26.0-0

so my next step would be to upgrade k8s cluster... I did not find any option to skip this check. I will proceed and post updated on the matter

gecube commented 9 months ago

Updated cluster to the latest version available:

kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.4", GitCommit:"fa3d7990104d7c1f16943a67f11b154b71f6a132", GitTreeState:"clean", BuildDate:"2023-07-19T12:14:48Z", GoVersion:"go1.20.6", Compiler:"gc", Platform:"darwin/arm64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"29+", GitVersion:"v1.29.0-eks-c417bb3", GitCommit:"787475c0c70a6bc04f58927faf4d30969314cf59", GitTreeState:"clean", BuildDate:"2023-12-13T19:28:31Z", GoVersion:"go1.21.5", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.27) and server (1.29) exceeds the supported minor version skew of +/-1

It allowed me to proceed further:

weave-enterprise % gitops bootstrap --export
► creating client to cluster
✔ created client to cluster: https://teleport.private.zodiamarkets.xyz:3026
◎ checking flux
► verifying flux installation
✔ flux is installed
► verifying flux reconcillation
✔ flux is bootstrapped
✔ detected git scheme: ssh
◎ bootstrap flux
◎ flux repository configuration
◎ git credentials
private key path: /Users/george/.ssh/id_rsa
private key password: 
◎ checking entitlement
► verifying Weave GitOps Entitlement File
Error: cannot execute bootstrap: error on step checking entitlement: cannot execute 'checking entitlement': entitlement file is not found, To get Weave GitOps Entitelment secret, please contact *sales@weave.works* and add it to your cluster: secrets "weave-gitops-enterprise-credentials" not found
gecube commented 9 months ago

Used entitlement from here: https://github.com/weaveworks/weave-gitops-enterprise/blob/main/test/utils/data/entitlement/entitlement-secret.yaml

gecube commented 9 months ago

Very weird:

gitops bootstrap --export
► creating client to cluster
✔ created client to cluster: https://teleport.private.zodiamarkets.xyz:3026
◎ checking flux
► verifying flux installation
✔ flux is installed
► verifying flux reconcillation
✔ flux is bootstrapped
✔ detected git scheme: ssh
◎ bootstrap flux
◎ flux repository configuration
◎ git credentials
private key path: /Users/george/.ssh/id_rsa
private key password: 
◎ checking entitlement
► verifying Weave GitOps Entitlement File
✔ entitlement file exists and is valid
◎ select WGE version
✔ 0.38.1
✔ selected version 0.38.1
◎ user authentication
⚠️  using existing admin login credentials from secret 'cluster-user-auth' in namespace 'flux-system'. To reset admin credentials please remove the secret
◎ Install Weave GitOps Enterprise
► installing v0.38.1 ... It may take a few minutes.
► rendered HelmRepository file
► rendered HelmRelease file
◎ Install OIDC
✗ Do you want to setup OIDC to access Weave GitOps Dashboards: 
◎ OIDC Configuration
◎ install extra components
✔ tf-controller
► installing Terraform Controller ...
Error: cannot execute bootstrap: error on step install extra components: cannot execute 'install extra components': can't install tf controller: cannot execute 'install Terraform Controller': helmreleases.helm.toolkit.fluxcd.io "weave-gitops-enterprise" not found

I can't install a tf-controller from the very beginning as weave-gitops-enterprise is not installed yet. In the same time policy controller is o.k. And I could not check both options :-(

gecube commented 9 months ago
# Run Weave GitOps Enterprise bootstrapping in interactive session writing resources to stdout 
gitops bootstrap --export  > bootstrap-weave-gitops-enterprise.yaml

It does not work at all, but hangs.

gecube commented 9 months ago

Incorrect check:

gitops check                                       
Error: ✗ kubernetes version v1.29.0-eks-c417bb3 does not match >=1.26
kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.4", GitCommit:"fa3d7990104d7c1f16943a67f11b154b71f6a132", GitTreeState:"clean", BuildDate:"2023-07-19T12:14:48Z", GoVersion:"go1.20.6", Compiler:"gc", Platform:"darwin/arm64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"29+", GitVersion:"v1.29.0-eks-c417bb3", GitCommit:"787475c0c70a6bc04f58927faf4d30969314cf59", GitTreeState:"clean", BuildDate:"2023-12-13T19:28:31Z", GoVersion:"go1.21.5", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.27) and server (1.29) exceeds the supported minor version skew of +/-1