Skip to content

Commit

Permalink
talos integration (#299)
Browse files Browse the repository at this point in the history
* talos integration

* remove k3s alias because not adapt to talos

* readd kuberneted aliases k3s and talos
  • Loading branch information
alessandroargentieri authored Feb 2, 2023
1 parent 257b6d1 commit 30153ee
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// KubernetesCmd manages Civo Kubernetes Clusters
var KubernetesCmd = &cobra.Command{
Use: "kubernetes",
Aliases: []string{"k3s", "k8s", "kube"},
Aliases: []string{"k3s", "k8s", "kube", "talos"},
Short: "Details of Civo Kubernetes clusters",
RunE: func(cmd *cobra.Command, args []string) error {
err := cmd.Help()
Expand Down Expand Up @@ -89,6 +89,7 @@ func init() {
kubernetesCreateCmd.Flags().StringVarP(&rulesFirewall, "firewall-rules", "u", "default", "optional, can be used if the --create-firewall flag is set, semicolon-separated list of ports to open")
kubernetesCreateCmd.Flags().BoolVarP(&createFirewall, "create-firewall", "c", false, "optional, create a firewall for the cluster with all open ports")
kubernetesCreateCmd.Flags().StringVarP(&cniPlugin, "cni-plugin", "p", "flannel", "optional, possible options: flannel,cilium.")
kubernetesCreateCmd.Flags().StringVarP(&clusterType, "cluster-type", "", "k3s", "optional, possible options: k3s,talos.")

kubernetesRenameCmd.Flags().StringVarP(&kubernetesNewName, "name", "n", "", "the new name for the cluster.")

Expand Down
3 changes: 2 additions & 1 deletion cmd/kubernetes/kubernetes_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
var numTargetNodes int
var rulesFirewall string
var waitKubernetes, saveConfigKubernetes, mergeConfigKubernetes, switchConfigKubernetes, createFirewall bool
var kubernetesVersion, targetNodesSize, clusterName, applications, removeapplications, networkID, existingFirewall, cniPlugin string
var kubernetesVersion, targetNodesSize, clusterName, clusterType, applications, removeapplications, networkID, existingFirewall, cniPlugin string
var kubernetesCluster *civogo.KubernetesCluster

var kubernetesCreateCmdExample = `civo kubernetes create CLUSTER_NAME [flags]
Expand Down Expand Up @@ -128,6 +128,7 @@ var kubernetesCreateCmd = &cobra.Command{
}
configKubernetes := &civogo.KubernetesClusterConfig{
Name: clusterName,
ClusterType: clusterType,
NumTargetNodes: numTargetNodes,
TargetNodesSize: targetNodesSize,
NetworkID: network.ID,
Expand Down
1 change: 1 addition & 0 deletions cmd/kubernetes/kubernetes_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ If you wish to use a custom format, the available fields are:

ow.AppendDataWithLabel("id", cluster.ID, "ID")
ow.AppendDataWithLabel("name", cluster.Name, "Name")
ow.AppendDataWithLabel("cluster_type", cluster.ClusterType, "Cluster-Type")
ow.AppendDataWithLabel("region", client.Region, "Region")
ow.AppendDataWithLabel("nodes", strconv.Itoa(len(cluster.Instances)), "Nodes")
ow.AppendDataWithLabel("pools", strconv.Itoa(len(cluster.Pools)), "Pools")
Expand Down
16 changes: 14 additions & 2 deletions cmd/kubernetes/kubernetes_list_version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package kubernetes

import (
"strings"

"github.com/civo/cli/common"
"github.com/civo/cli/config"
"github.com/civo/cli/utility"
Expand Down Expand Up @@ -48,8 +50,18 @@ If you wish to use a custom format, the available fields are:

ow.StartLine()

ow.AppendDataWithLabel("version", version.Version, "Version")
ow.AppendDataWithLabel("type", version.Type, "Type")
if version.ClusterType == "" {
if strings.Contains(version.Label, "k3s") {
version.ClusterType = "k3s"
} else {
version.ClusterType = "talos"
}
}

ow.AppendDataWithLabel("label", version.Label, "Name")
ow.AppendDataWithLabel("version", version.Version, "K8s version")
ow.AppendDataWithLabel("cluster_type", version.ClusterType, "Cluster-Type")
ow.AppendDataWithLabel("type", version.Type, "Maturity")
ow.AppendDataWithLabel("default", strconv.FormatBool(version.Default), "Default")
}

Expand Down
1 change: 1 addition & 0 deletions cmd/kubernetes/kubernetes_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ If you wish to use a custom format, the available fields are:

ow.AppendData("ID", kubernetesCluster.ID)
ow.AppendData("Name", kubernetesCluster.Name)
ow.AppendData("ClusterType", kubernetesCluster.ClusterType)
ow.AppendData("Region", client.Region)
ow.AppendData("Nodes", strconv.Itoa(len(kubernetesCluster.Instances)))
ow.AppendData("Size", kubernetesCluster.TargetNodeSize)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/briandowns/spinner v1.11.1
github.com/c4milo/unpackit v0.0.0-20170704181138-4ed373e9ef1c // indirect
github.com/civo/civogo v0.3.23
github.com/civo/civogo v0.3.24
github.com/dsnet/compress v0.0.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/google/go-github v17.0.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/civo/civogo v0.3.23 h1:FTSad682Qu7CsjkNAYWpSe2CSR1NJOE2NRxc6gUzHDk=
github.com/civo/civogo v0.3.23/go.mod h1:SbS06e0JPgIF27r1sLC97gjU1xWmONQeHgzF1hfLpak=
github.com/civo/civogo v0.3.24 h1:7kXEhtVUFkWIunNePqPCcIUilOktnXLWrKfi5sDqBNQ=
github.com/civo/civogo v0.3.24/go.mod h1:SbS06e0JPgIF27r1sLC97gjU1xWmONQeHgzF1hfLpak=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down

0 comments on commit 30153ee

Please sign in to comment.