Skip to content

Commit

Permalink
add multi-cluster docs to README
Browse files Browse the repository at this point in the history
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
  • Loading branch information
chanwit committed Feb 27, 2024
1 parent 6acca41 commit fcd2a9d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,46 @@ After that you can port forward and open your browser to http://localhost:8080
```shell
kubectl -n argocd port-forward svc/argocd-server 8080:443
```

## Multi-cluster support

### What is Flamingo multi-cluster support?

Flamingo multi-cluster is a feature designed to visualize multiple Flux clusters in the Flamingo UI.
We use ArgoCD cluster secrets to store cluster information for Flamingo multi-cluster support.
To list clusters, use the following command:

```shell
flamingo list-clusters
```

To register a Kubernetes cluster with Flamingo, simply use the `add-cluster` command.
For example, the following command adds the `dev-1` cluster definition from the `KUBECONFIG` file, then overrides the server name and server address, and sets it to skip TLS verification.

```shell
flamingo add-cluster dev-1 \
--server-name=dev-1.vcluster-dev-1 \
--server-addr=https://dev-1.vcluster-dev-1.svc \
--insecure
```

This `add-cluster` command currently supports adding a cluster with static credentials, such as client certs and client keys (like Vclusters), but does not yet support authentication via KubeClient plugins. For clusters like EKS and others, you need to create cluster secrets manually.

To generate applications from Flux workloads on leaf clusters, the flamingo `generate-app` command has been extended to support the resource format as `cluster/kind/object-name`, for example:

```shell
flamingo generate-app \
dev-1/ks/podinfo
```

The above command will generate an application named `podinfo` from the `ks` resource on the `dev-1` cluster.
This `generate-app` command uses Flamingo cluster information to connect to the leaf cluster and generate the application.
Currently, this command only supports static cluster credentials with client certs and keys.
For dynamic cluster credentials like in EKS and others, you would use the `--context` flag to select the Kube's context for the leaf cluster and generate the application with the `--server` flag to override the destination cluster, like:

```shell
flamingo generate-app \
--context=dev-1 \
--server=https://dev-1.vcluster-dev-1.svc \
ks/podinfo --export | kubectl apply -f -
```
10 changes: 9 additions & 1 deletion cmd/flamingo/generate_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ flamingo generate-app \

var generateAppFlags struct {
appName string
server string
export bool
}

func init() {
generateAppCmd.Flags().StringVar(&generateAppFlags.appName, "app-name", "", "export the generated application to stdout")
// app name should be default to the resource name
generateAppCmd.Flags().StringVar(&generateAppFlags.appName, "app-name", "", "name of the generated application")
generateAppCmd.Flags().StringVar(&generateAppFlags.server, "server", "", "server URL to override the destination cluster")
generateAppCmd.Flags().BoolVar(&generateAppFlags.export, "export", false, "export the generated application to stdout")

rootCmd.AddCommand(generateAppCmd)
Expand Down Expand Up @@ -122,6 +125,11 @@ func generateAppCmdRun(_ *cobra.Command, args []string) error {
}
}

// Override the server URL if provided
if generateAppFlags.server != "" {
clusterConfig.Server = generateAppFlags.server
}

var tpl bytes.Buffer
if kindName == kustomizev1.KustomizationKind {
if err := generateKustomizationApp(leafCli, appName, objectName, kindName, clusterName, clusterConfig.Server, &tpl); err != nil {
Expand Down

0 comments on commit fcd2a9d

Please sign in to comment.