Documentation ¶
Index ¶
- Variables
- func Contains(a []string, x string) bool
- func GlobalPreRun(cmd *cobra.Command, args []string)
- func MakeAbsolute(path *string) error
- func NewConfig(paths []string, extras []string) types.PlatformConfigdeprecated
- func NewConfigFromBase(base types.PlatformConfig, paths []string, extras []string) types.PlatformConfig
- type KubeTypes
- type Pair
- type TestFn
Constants ¶
This section is empty.
Variables ¶
View Source
var APIDocs = &cobra.Command{ Use: "api", Short: "Generate docs ", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { printAPIDocs(args) }, }
View Source
var Access = &cobra.Command{
Use: "kubeconfig",
Short: "Generate kubeconfig files",
}
View Source
var Apply = &cobra.Command{ Use: "apply", Short: "Apply a configuration to a resource by filename", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { ns, _ := cmd.Flags().GetString("namespace") p := getPlatform(cmd) for _, spec := range args { data, err := ioutil.ReadFile(spec) if err != nil { log.Fatalf("Could not read %s: %v", spec, err) } template, err := p.TemplateText(string(data)) if err != nil { log.Fatalf("failed to template %s: %v", spec, err) } if err := p.ApplyText(ns, template); err != nil { log.Fatalf("failed to apply %s: %v", spec, err) } } }, }
View Source
var Backup = &cobra.Command{ Use: "backup", Short: "Create new velero backup", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { if _, err := velero.CreateBackup(getPlatform(cmd)); err != nil { log.Fatalf("Error creating backup %v", err) } }, }
View Source
var BurninController = &cobra.Command{ Use: "burnin-controller", Run: func(cmd *cobra.Command, args []string) { burninCancel := make(chan bool) burnin.Run(getPlatform(cmd), burninControllerPeriod, burninCancel) }, }
View Source
var CA = &cobra.Command{
Use: "ca",
Short: "Commands for generating CA certs",
}
View Source
var Cleanup = &cobra.Command{
Use: "cleanup",
Short: "remove all failed jobs or pods",
}
View Source
var Config = &cobra.Command{
Use: "config",
Short: "Commands for working with config files",
}
View Source
var Conformance = &cobra.Command{ Use: "conformance", Short: "Run conformance tests using sonobuoy", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { if err := phases.ConformanceTest(getPlatform(cmd), phases.ConformanceTestOptions{ Certification: certification, KubeBench: kubeBench, Quick: quick, Wait: wait, OutputDir: outputDir, }); err != nil { log.Fatalf("Failed to run conformance tests: %v", err) } }, }
View Source
var Consul = &cobra.Command{
Use: "consul",
}
View Source
var DB = &cobra.Command{
Use: "db",
}
View Source
var DNS = &cobra.Command{
Use: "dns",
}
View Source
var Dashboard = &cobra.Command{
Use: "dashboard",
}
View Source
var Deploy = &cobra.Command{
Use: "deploy",
}
View Source
var Exec = &cobra.Command{ Use: "exec", Short: "Execute a shell command inside pods matching selector", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { command := args[0] args = args[1:] if len(args) > 0 { command = command + " " + strings.Join(args, " ") } ns, _ := cmd.Flags().GetString("namespace") container, _ := cmd.Flags().GetString("container") selector, _ := cmd.Flags().GetString("selector") p := getPlatform(cmd) client, err := p.GetClientset() if err != nil { log.Fatalf("unable to get clientset: %v", err) } pods, err := client.CoreV1().Pods(ns).List(context.TODO(), metav1.ListOptions{LabelSelector: selector}) if err != nil { log.Fatalf("unable to list pods: %v", err) } for _, pod := range pods.Items { if pod.Status.Phase != v1.PodRunning { log.Warnf("Skipping %s in %s phase", pod.Name, pod.Status.Phase) continue } _container := container if _container == "" { _container = pod.Spec.Containers[0].Name } stdout, stderr, err := p.ExecutePodf(ns, pod.Name, _container, command) if err != nil { log.Errorf("[%s/%s] %s %s %v", pod.Name, _container, stdout, stderr, err) } else { log.Infof("[%s/%s] %s %s", pod.Name, _container, stdout, stderr) } } }, }
View Source
var ExecNode = &cobra.Command{ Use: "exec-node", Short: "Execute a shell command inside host mounted daemonset on each node", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { command := args[0] args = args[1:] if len(args) > 0 { command = command + " " + strings.Join(args, " ") } selector, _ := cmd.Flags().GetString("selector") p := getPlatform(cmd) client, err := p.GetClientset() if err != nil { log.Fatalf("unable to get clientset: %v", err) } nodes, err := client.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{ LabelSelector: selector, }) if err != nil { log.Fatalf("unable to list nodes: %v", err) } for _, node := range nodes.Items { stdout, err := p.Executef(node.Name, 60*time.Second, command) if err != nil { log.Errorf("[%s] %s %v", node.Name, stdout, err) } else { log.Infof("[%s] %s", node.Name, stdout) } } }, }
View Source
var Harbor = &cobra.Command{
Use: "harbor",
Short: "Commmands for deploying and interacting with harbor",
}
Harbor is the parent command for interactor with the harbor docker registry
View Source
var Images = &cobra.Command{
Use: "images",
Short: "Commands for working with docker images",
}
View Source
var Logs = &cobra.Command{ Use: "logs", Short: "Retrieve and export logs from ElasticSearch", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { name, _ := cmd.Flags().GetString("name") kql, _ := cmd.Flags().GetString("query") pod, _ := cmd.Flags().GetString("pod") count, _ := cmd.Flags().GetInt("count") namespace, _ := cmd.Flags().GetString("namespace") cluster, _ := cmd.Flags().GetString("cluster") since, _ := cmd.Flags().GetString("since") from, _ := cmd.Flags().GetString("from") to, _ := cmd.Flags().GetString("to") timestamps, _ := cmd.Flags().GetBool("timestamps") if err := elastic.ExportLogs(getPlatform(cmd), name, elastic.Query{ Pod: pod, Count: count, Cluster: cluster, Namespace: namespace, Since: since, Query: kql, From: from, Timestamps: timestamps, To: to, }); err != nil { log.Fatalf("Failed to export logs, %s", err) } }, }
View Source
var MachineImages = &cobra.Command{ Use: "machine-images", Aliases: []string{"vm"}, Short: "Commands for working with machine images", }
View Source
var NSX = &cobra.Command{
Use: "nsx",
Short: "Commands for interacting with NSX clusters",
}
View Source
var Namespace = &cobra.Command{
Use: "namespace",
Short: "Commands for manipulating namespaces",
}
View Source
var Node = &cobra.Command{
Use: "node",
Short: "Commands for interacting with Kubernetes nodes",
}
View Source
var Operator = &cobra.Command{ Use: "operator", Short: "Run karina operator", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { metricsAddr, _ := cmd.Flags().GetString("metrics-addr") enableLeaderElection, _ := cmd.Flags().GetBool("enable-leader-election") syncPeriod, _ := cmd.Flags().GetDuration("sync-period") logLevel, _ := cmd.Flags().GetString("log-level") port, _ := cmd.Flags().GetInt("port") operatorConfig := operator.Config{ MetricsAddr: metricsAddr, EnableLeaderElection: enableLeaderElection, SyncPeriod: syncPeriod, LogLevel: logLevel, Port: port, } op, err := operator.New(operatorConfig) if err != nil { log.Fatalf("failed to create operator: %v", err) } if err := op.Run(); err != nil { log.Fatalf("failed to start operator: %v", err) } }, }
View Source
var Orphan = &cobra.Command{ Use: "orphan", Short: "Remove owner references from an object", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { platform := getPlatform(cmd) kind := args[0] name := args[1] namespace, _ := cmd.Flags().GetString("namespace") object, found := constants.RuntimeObjects[kind] if !found { if err := platform.OrphanCRD(kind, name, namespace); err != nil { platform.Fatalf("failed to orphan %s %s in namespace %s: %v", kind, name, namespace, err) } } else { if err := platform.Orphan(kind, name, namespace, object); err != nil { platform.Fatalf("failed to orphan %s %s in namespace %s: %v", kind, name, namespace, err) } } }, }
View Source
var Provision = &cobra.Command{
Use: "provision",
Short: "Commands for provisioning clusters and VMs",
}
View Source
var Render = &cobra.Command{ Use: "render", Short: "Generate kubeconfig files", Run: func(cmd *cobra.Command, args []string) { base := getConfig(cmd) data, _ := yaml.Marshal(base) fmt.Println(string(data)) }, }
View Source
var Report = &cobra.Command{
Use: "report",
}
View Source
var Rolling = &cobra.Command{
Use: "rolling",
}
View Source
var RollingRestart = &cobra.Command{ Use: "restart", Short: "Rolling restart of all nodes", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { if err := provision.RollingRestart(getPlatform(cmd), rollingOpts); err != nil { log.Fatalf("Failed to restart nodes, %s", err) } }, }
View Source
var RollingUpdate = &cobra.Command{ Use: "update", Short: "Rolling update of all nodes", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { if err := provision.RollingUpdate(getPlatform(cmd), rollingOpts); err != nil { log.Fatalf("Failed to update nodes %s", err) os.Exit(1) } }, }
View Source
var Seal = &cobra.Command{ Use: "seal", Short: "Seal a secret using sealed-secrets", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { p := getPlatform(cmd) flags := []string{ getFlagString("format", cmd), getFlagFilePath("merge-into", cmd), getFlagBool("re-encrypt", cmd), getFlagString("name", cmd), getFlagFilePathSlice("from-file", cmd), } if !p.SealedSecrets.Disabled && p.SealedSecrets.Certificate != nil { if p.SealedSecrets.Certificate.Cert == "" { log.Fatalf("Sealed-secrets certificate not provided in config") } flags = append(flags, "--cert", p.SealedSecrets.Certificate.Cert) } kubeseal := p.GetBinary("kubeseal") flagString := strings.Join(flags, " ") argString := strings.Join(args, " ") if err := kubeseal(flagString + argString); err != nil { log.Fatalf("failed to run kubeseal: %v", err) } }, }
View Source
var Snapshot = &cobra.Command{ Use: "snapshot", Short: "Take a snapshot of the running system", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { opts.Namespaces = args if err := snapshot.Take(getPlatform(cmd), opts); err != nil { log.Fatalf("Failed to get cluster snapshot, %s", err) } }, }
View Source
var Status = &cobra.Command{ Use: "status", Short: "Print the status of the cluster and each node", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { if err := provision.Status(getPlatform(cmd)); err != nil { logger.Fatalf("Failed to get cluster status, %s", err) } }, }
View Source
var Terminate = &cobra.Command{ Use: "terminate", Short: "Terminate a cluster and destroy all VM's and resources associated with it", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { if err := provision.Terminate(getPlatform(cmd)); err != nil { log.Fatalf("Failed to cleanup cluster, %s", err) } }, }
View Source
var TerminateNodes = &cobra.Command{ Use: "terminate-node [nodes]", Short: "Cordon and terminate the specified nodes", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { if err := provision.TerminateNodes(getPlatform(cmd), args); err != nil { log.Fatalf("Failed terminate nodes %s", err) } }, }
View Source
var TerminateOrphans = &cobra.Command{ Use: "terminate-orphans", Short: "Terminate all orphaned VM's that have not successfully joined the cluster", Run: func(cmd *cobra.Command, args []string) { if err := provision.TerminateOrphans(getPlatform(cmd)); err != nil { log.Fatalf("Failed terminate nodes %s", err) } }, }
View Source
var Test = &cobra.Command{
Use: "test",
}
View Source
var Undelete = &cobra.Command{ Use: "undelete", Short: "Undelete kubernetes objects", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { platform := getPlatform(cmd) kind := args[0] name := args[1] namespace, _ := cmd.Flags().GetString("namespace") object, found := constants.RuntimeObjects[kind] if !found { if err := platform.UndeleteCRD(kind, name, namespace); err != nil { platform.Fatalf("failed to undelete %s %s in namespace %s: %v", kind, name, namespace, err) } } else { if err := platform.Undelete(kind, name, namespace, object); err != nil { platform.Fatalf("failed to undelete %s %s in namespace %s: %v", kind, name, namespace, err) } } }, }
View Source
var Unseal = &cobra.Command{ Use: "unseal", Short: "Unseal a secret using sealed-secrets", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { p := getPlatform(cmd) filePath, err := filepath.Abs(privateKeyFile) if err != nil { log.Fatalf("Unable to resolve file path for %s: %v", privateKeyFile, err) } flags := []string{ "--recovery-unseal", getFlagString("format", cmd), fmt.Sprintf("--recovery-private-key %s", filePath), } if !p.SealedSecrets.Disabled && p.SealedSecrets.Certificate != nil { if p.SealedSecrets.Certificate.Cert == "" { log.Fatalf("Sealed-secrets certificate not provided in config") } flags = append(flags, "--cert", p.SealedSecrets.Certificate.Cert) } isOffline, _ := cmd.Flags().GetBool("offline") var secret corev1.Secret if isOffline { if p.SealedSecrets.Certificate.PrivateKey == "" { log.Fatalf("Sealed-secrets private key not provided in config") } secret, err = getOfflineCertificate(p) if err != nil { log.Fatalf("Unable to get sealed-secrets private key from file: %v", err) } } else { secret, err = getOnlineCertificate(p) if err != nil { log.Fatalf("Unable to get sealed-secrets active private key from cluster: %v", err) } } file, err := json.Marshal(secret) if err != nil { log.Fatalf("Unable to get marshal secret to JSON: %v", err) } err = ioutil.WriteFile(privateKeyFile, file, 0600) defer os.Remove(privateKeyFile) if err != nil { log.Fatalf("Unable to write sealed-secrets-key to disk: %v", err) } kubeseal := p.GetBinary("kubeseal") flagString := strings.Join(flags, " ") argString := strings.Join(args, " ") if err := kubeseal(flagString + argString); err != nil { log.Fatalf("failed to run kubeseal: %v", err) } }, }
View Source
var Upgrade = &cobra.Command{ Use: "upgrade", Short: "Upgrade the kubernetes control plane", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { if err := provision.Upgrade(getPlatform(cmd)); err != nil { logger.Fatalf("Failed to upgrade cluster, %s", err) } }, }
View Source
var Vault = &cobra.Command{
Use: "vault",
Short: "Commands for working with vault",
}
Functions ¶
func GlobalPreRun ¶
func MakeAbsolute ¶ added in v0.44.0
func NewConfig
deprecated
func NewConfig(paths []string, extras []string) types.PlatformConfig
Deprecated: use NewConfigFromBase instead
func NewConfigFromBase ¶ added in v0.47.0
func NewConfigFromBase(base types.PlatformConfig, paths []string, extras []string) types.PlatformConfig
Types ¶
type KubeTypes ¶
type KubeTypes []Pair
KubeTypes is an array to represent all available types in a parsed file. [0] is for the type itself
func ParseDocumentationFrom ¶
ParseDocumentationFrom gets all types' documentation and returns them as an array. Each type is again represented as an array (we have to use arrays as we need to be sure for the order of the fields). This function returns fields and struct definitions that have no documentation as {name, ""}.
Source Files ¶
- access.go
- apply.go
- backup.go
- ca.go
- cleanup.go
- common.go
- config.go
- conformance.go
- consul.go
- contoller.go
- dashboard.go
- db.go
- deploy.go
- dns.go
- docker-images.go
- docs.go
- exec.go
- harbor.go
- logs.go
- machine-images.go
- namespace.go
- node.go
- nsx.go
- operator.go
- orphan.go
- provision.go
- report.go
- rolling.go
- seal.go
- snapshot.go
- status.go
- terminate.go
- test.go
- undelete.go
- unseal.go
- upgrade.go
- vault.go
- vm.go
Click to show internal directories.
Click to hide internal directories.