Add airshipctl cluster init command
Change-Id: Ieb23b3e313126a69e8c3256f5178651ff40a80f9
This commit is contained in:
parent
0e17d6c7f3
commit
1e97f2b480
@ -37,6 +37,7 @@ func NewClusterCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Comm
|
|||||||
}
|
}
|
||||||
|
|
||||||
clusterRootCmd.AddCommand(NewInitInfraCommand(rootSettings))
|
clusterRootCmd.AddCommand(NewInitInfraCommand(rootSettings))
|
||||||
|
clusterRootCmd.AddCommand(NewInitCommand(rootSettings))
|
||||||
|
|
||||||
return clusterRootCmd
|
return clusterRootCmd
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,11 @@ func TestNewClusterCommand(t *testing.T) {
|
|||||||
CmdLine: "--help",
|
CmdLine: "--help",
|
||||||
Cmd: cluster.NewClusterCommand(fakeRootSettings),
|
Cmd: cluster.NewClusterCommand(fakeRootSettings),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "cluster-init-cmd-with-help",
|
||||||
|
CmdLine: "--help",
|
||||||
|
Cmd: cluster.NewInitCommand(fakeRootSettings),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, testcase := range tests {
|
for _, testcase := range tests {
|
||||||
testutil.RunTest(t, testcase)
|
testutil.RunTest(t, testcase)
|
||||||
|
89
cmd/cluster/init.go
Normal file
89
cmd/cluster/init.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2014 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cluster
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
clusterctlcmd "opendev.org/airship/airshipctl/pkg/clusterctl/cmd"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/environment"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
initLong = `
|
||||||
|
Initialize cluster-api providers based on airshipctl document set.
|
||||||
|
document set must contain document of Kind: Clusterctl in phase initinfra.
|
||||||
|
Path to initinfra phase is built based on airshipctl config
|
||||||
|
<manifest.target-path>/<subpath>/ephemeral/initinfra.
|
||||||
|
Clusterctl document example:
|
||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: Clusterctl
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
airshipit.org/deploy-k8s: "false"
|
||||||
|
name: clusterctl-v1
|
||||||
|
init-options:
|
||||||
|
core-provider: "cluster-api:v0.3.3"
|
||||||
|
bootstrap-providers:
|
||||||
|
- "kubeadm:v0.3.3"
|
||||||
|
infrastructure-providers:
|
||||||
|
- "metal3:v0.3.1"
|
||||||
|
control-plane-providers:
|
||||||
|
- "kubeadm:v0.3.3"
|
||||||
|
providers:
|
||||||
|
- name: "metal3"
|
||||||
|
type: "InfrastructureProvider"
|
||||||
|
versions:
|
||||||
|
v0.3.1: manifests/function/capm3/v0.3.1
|
||||||
|
- name: "kubeadm"
|
||||||
|
type: "BootstrapProvider"
|
||||||
|
versions:
|
||||||
|
v0.3.3: manifests/function/cabpk/v0.3.3
|
||||||
|
- name: "cluster-api"
|
||||||
|
type: "CoreProvider"
|
||||||
|
versions:
|
||||||
|
v0.3.3: manifests/function/capi/v0.3.3
|
||||||
|
- name: "kubeadm"
|
||||||
|
type: "ControlPlaneProvider"
|
||||||
|
versions:
|
||||||
|
v0.3.3: manifests/function/cacpk/v0.3.3
|
||||||
|
`
|
||||||
|
|
||||||
|
initExample = `
|
||||||
|
# Initialize clusterctl providers and components
|
||||||
|
airshipctl cluster init
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewInitCommand creates a command to deploy cluster-api
|
||||||
|
func NewInitCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||||
|
initCmd := &cobra.Command{
|
||||||
|
Use: "init",
|
||||||
|
Short: "Deploy cluster-api provider components",
|
||||||
|
Long: initLong,
|
||||||
|
Example: initExample,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
command, err := clusterctlcmd.NewCommand(rootSettings)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return command.Init()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return initCmd
|
||||||
|
}
|
@ -6,6 +6,7 @@ Usage:
|
|||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
help Help about any command
|
help Help about any command
|
||||||
|
init Deploy cluster-api provider components
|
||||||
initinfra Deploy initinfra components to cluster
|
initinfra Deploy initinfra components to cluster
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
|
50
cmd/cluster/testdata/TestNewClusterCommandGoldenOutput/cluster-init-cmd-with-help.golden
vendored
Normal file
50
cmd/cluster/testdata/TestNewClusterCommandGoldenOutput/cluster-init-cmd-with-help.golden
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
Initialize cluster-api providers based on airshipctl document set.
|
||||||
|
document set must contain document of Kind: Clusterctl in phase initinfra.
|
||||||
|
Path to initinfra phase is built based on airshipctl config
|
||||||
|
<manifest.target-path>/<subpath>/ephemeral/initinfra.
|
||||||
|
Clusterctl document example:
|
||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: Clusterctl
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
airshipit.org/deploy-k8s: "false"
|
||||||
|
name: clusterctl-v1
|
||||||
|
init-options:
|
||||||
|
core-provider: "cluster-api:v0.3.3"
|
||||||
|
bootstrap-providers:
|
||||||
|
- "kubeadm:v0.3.3"
|
||||||
|
infrastructure-providers:
|
||||||
|
- "metal3:v0.3.1"
|
||||||
|
control-plane-providers:
|
||||||
|
- "kubeadm:v0.3.3"
|
||||||
|
providers:
|
||||||
|
- name: "metal3"
|
||||||
|
type: "InfrastructureProvider"
|
||||||
|
versions:
|
||||||
|
v0.3.1: manifests/function/capm3/v0.3.1
|
||||||
|
- name: "kubeadm"
|
||||||
|
type: "BootstrapProvider"
|
||||||
|
versions:
|
||||||
|
v0.3.3: manifests/function/cabpk/v0.3.3
|
||||||
|
- name: "cluster-api"
|
||||||
|
type: "CoreProvider"
|
||||||
|
versions:
|
||||||
|
v0.3.3: manifests/function/capi/v0.3.3
|
||||||
|
- name: "kubeadm"
|
||||||
|
type: "ControlPlaneProvider"
|
||||||
|
versions:
|
||||||
|
v0.3.3: manifests/function/cacpk/v0.3.3
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
init [flags]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
# Initialize clusterctl providers and components
|
||||||
|
airshipctl cluster init
|
||||||
|
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
-h, --help help for init
|
Loading…
Reference in New Issue
Block a user