UffizziCloud / uffizzi_cli

The command-line interface for the Uffizzi API
Apache License 2.0
87 stars 46 forks source link

uffizzi CLI updates for virtual cluster support #221

Open gadkins opened 1 year ago

gadkins commented 1 year ago

The uffizzi CLI will need to support virtual cluster operations

gadkins commented 1 year ago
uffizzi cluster help

  uffizzi cluster create                        # Create an ephemeral cluster  
  uffizzi cluster apply [CLUSTER_ID] -f [MANIFEST_FILENAME]   # apply a new ephemeral cluster configuration
  uffizzi cluster update [CLUSTER_ID]           # Update metadata of an ephemeral cluster
  uffizzi cluster delete [CLUSTER_ID]           # Delete an ephemeral cluster
  uffizzi cluster describe [CLUSTER_ID]         # Display details of an ephemeral cluster
  uffizzi cluster help [COMMAND]                # Describe subcommands or one specific subcommand
axisofentropy commented 1 year ago

I'd like to add a command to update the user's kubeconfig file, maybe uffizzi cluster configure or connect. This might behave similar to gcloud container clusters get-credentials or aws eks update-kubeconfig.

gadkins commented 1 year ago

User story

$ uffizzi cluster create [NAME]   # Creates empty cluster
$ uffizzi cluster create --generate-name  # (alternatively)
$ uffizzi cluster create -f [MANIFEST_FILENAME] --generate-name
# Outputs information about the virtual cluster that was created
# Updates the user’s kubeconfig

$ uffizzi cluster list -o wide
# Outputs cluster names, age, host, or if passed with `-o wide also outputs source repo, commit id

$ uffizzi cluster describe [NAME]
# Output cluster services, 

$ uffizzi cluster services list [NAME]
# Output name, namespace, host 

$ uffizzi cluster connect [NAME] 
# updates kubeconfig or creates it if does not exist

# Pipelie build and push images
# Interpolate values.uffizzi.yaml with updated images
# Create a manifest
# Option 1: helm release ${PR-number}-{commit-ID}-{account}-{project} [CHART] > manifests.yaml
# Option 2: kustomize … > manifest.yml
$ uffizzi cluster update [NAME] manifest.yaml 
moklidia commented 1 year ago

@axisofentropy @gadkins @jpthurman

The virtual cluster accepts the helm chart and can create a deployment based on this helm chart automatically right after creation, all we need to do is provide it with a manifest like this:

kind: UffizziCluster
apiVersion: uffizzi.com/v1alpha1
metadata:
  name: testnode
  namespace: test-node
spec:
  ingress:
    class: "nginx"
    host: deleteme2023.uffizzi.cloud
    services:
    - name: test-node-svc
      namespace: test-node
      port: 8080
      ingressAnnotations:
        cert-manager.io/cluster-issuer: "my-uffizzi-letsencrypt"
      certManagerTLSEnabled: true
  ttl: 1h
  components: 'helm'
  helm:
  - chart:
      name: test-node
      repo: https://zipofar.github.io/test_node
    release:
      name: test-node
      namespace: test-node

I wonder if the uffizzi cluster commands and others are redundant and instead, we can let users use our existing uffizzi preview create command with the --helm option. The platform can define whether to create a cluster or not based on this option.

gadkins commented 1 year ago

@moklidia Maybe, but as discussed, we probably want to support k8s manifests, not just helm.

Also, I'd like to migrate to environment or (env) instead of preview.

Maybe...

$ uffizzi env create --cluster -f [MANIFEST]

# or

$ uffizzi env create --helm [CHART_DIR] values.uffizzi.yaml