[AIR-97] Adding initinfra subcommand
Command will deploy initial inftrastructure that is identified by airshipctl document module, bundle interface, documents will be fitered based on label and annotation, which will indicate that it belongs to initial infrastructure. After the documents are identified, they will be labeled indicating that these resources are deployed by initinfra, if flag `prune` is specified, resources that have initinfra annotation and deployedBy initinfra label, but are not part of the documents supplied by bundle interface will be deleted. If user wants to avoid pruning of some resources he can remove label deployBy manually from the kubernetes resources that should not prunned. Change-Id: I143835291d449be420bfcb2944ba7eaec37c3411
This commit is contained in:
parent
8cf0247086
commit
e1bc8ee07d
@ -20,5 +20,7 @@ func NewClusterCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Comm
|
|||||||
Long: "Interactions with Kubernetes cluster, such as get status, deploy initial infrastructure",
|
Long: "Interactions with Kubernetes cluster, such as get status, deploy initial infrastructure",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clusterRootCmd.AddCommand(NewCmdInitInfra(rootSettings))
|
||||||
|
|
||||||
return clusterRootCmd
|
return clusterRootCmd
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,26 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"opendev.org/airship/airshipctl/cmd/cluster"
|
"opendev.org/airship/airshipctl/cmd/cluster"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/environment"
|
||||||
"opendev.org/airship/airshipctl/testutil"
|
"opendev.org/airship/airshipctl/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewClusterCommandReturn(t *testing.T) {
|
func TestNewClusterCommandReturn(t *testing.T) {
|
||||||
|
fakeRootSettings := &environment.AirshipCTLSettings{}
|
||||||
|
fakeRootSettings.SetAirshipConfigPath("../../testdata/k8s/config.yaml")
|
||||||
|
fakeRootSettings.SetKubeConfigPath("../../testdata/k8s/kubeconfig.yaml")
|
||||||
|
fakeRootSettings.InitConfig()
|
||||||
|
|
||||||
tests := []*testutil.CmdTest{
|
tests := []*testutil.CmdTest{
|
||||||
{
|
{
|
||||||
Name: "cluster-cmd-with-defaults",
|
Name: "cluster-cmd-with-defaults",
|
||||||
CmdLine: "",
|
CmdLine: "",
|
||||||
Cmd: cluster.NewClusterCommand(nil),
|
Cmd: cluster.NewClusterCommand(fakeRootSettings),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "cluster-initinfra-cmd-with-defaults",
|
||||||
|
CmdLine: "--help",
|
||||||
|
Cmd: cluster.NewCmdInitInfra(fakeRootSettings),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, testcase := range tests {
|
for _, testcase := range tests {
|
||||||
|
71
cmd/cluster/initinfra.go
Normal file
71
cmd/cluster/initinfra.go
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
|
||||||
|
"opendev.org/airship/airshipctl/pkg/cluster/initinfra"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/environment"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// TODO add labels in description, when we have them designed
|
||||||
|
getInitInfraLong = `Deploy initial infrastructure to kubernetes cluster such as` +
|
||||||
|
`metal3.io, argo, tiller and other manifest documents with appropriate labels`
|
||||||
|
getInitInfraExample = `#deploy infra to cluster
|
||||||
|
airshipctl cluster initinfra`
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewCmdInitInfra creates a command to deploy initial airship infrastructure
|
||||||
|
func NewCmdInitInfra(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||||
|
i := initinfra.NewInfra(rootSettings)
|
||||||
|
initinfraCmd := &cobra.Command{
|
||||||
|
Use: "initinfra",
|
||||||
|
Short: "deploy initinfra components to cluster",
|
||||||
|
Long: getInitInfraLong,
|
||||||
|
Example: getInitInfraExample,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
return i.Run()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
addInitinfraFlags(i, initinfraCmd)
|
||||||
|
return initinfraCmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func addInitinfraFlags(i *initinfra.Infra, cmd *cobra.Command) {
|
||||||
|
flags := cmd.Flags()
|
||||||
|
flags.BoolVar(
|
||||||
|
&i.DryRun,
|
||||||
|
"dry-run",
|
||||||
|
false,
|
||||||
|
"Don't deliver documents to the cluster, see the changes instead")
|
||||||
|
|
||||||
|
flags.BoolVar(
|
||||||
|
&i.Prune,
|
||||||
|
"prune",
|
||||||
|
false,
|
||||||
|
`If set to true, command will delete all kubernetes resources that are not`+
|
||||||
|
` defined in airship documents and have airshipit.org/deployed=initinfra label`)
|
||||||
|
|
||||||
|
flags.StringVar(
|
||||||
|
&i.ClusterType,
|
||||||
|
"cluster-type",
|
||||||
|
"ephemeral",
|
||||||
|
`Select cluster type to be deploy initial infastructure to,`+
|
||||||
|
` currently only ephemeral is supported`)
|
||||||
|
}
|
@ -1,2 +1,13 @@
|
|||||||
Interactions with Kubernetes cluster, such as get status, deploy initial infrastructure
|
Interactions with Kubernetes cluster, such as get status, deploy initial infrastructure
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
cluster [command]
|
||||||
|
|
||||||
|
Available Commands:
|
||||||
|
help Help about any command
|
||||||
|
initinfra deploy initinfra components to cluster
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
-h, --help help for cluster
|
||||||
|
|
||||||
|
Use "cluster [command] --help" for more information about a command.
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
Deploy initial infrastructure to kubernetes cluster such asmetal3.io, argo, tiller and other manifest documents with appropriate labels
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
initinfra [flags]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
#deploy infra to cluster
|
||||||
|
airshipctl cluster initinfra
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
--cluster-type string Select cluster type to be deploy initial infastructure to, currently only ephemeral is supported (default "ephemeral")
|
||||||
|
--dry-run Don't deliver documents to the cluster, see the changes instead
|
||||||
|
-h, --help help for initinfra
|
||||||
|
--prune If set to true, command will delete all kubernetes resources that are not defined in airship documents and have airshipit.org/deployed=initinfra label
|
@ -5,6 +5,7 @@ Usage:
|
|||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
bootstrap Bootstrap ephemeral Kubernetes cluster
|
bootstrap Bootstrap ephemeral Kubernetes cluster
|
||||||
|
cluster Control Kubernetes cluster
|
||||||
completion Generate autocompletions script for the specified shell (bash or zsh)
|
completion Generate autocompletions script for the specified shell (bash or zsh)
|
||||||
config Modify airshipctl config files
|
config Modify airshipctl config files
|
||||||
document manages deployment documents
|
document manages deployment documents
|
||||||
@ -18,7 +19,4 @@ Flags:
|
|||||||
-h, --help help for airshipctl
|
-h, --help help for airshipctl
|
||||||
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
|
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
|
||||||
|
|
||||||
Additional help topics:
|
|
||||||
airshipctl cluster Control Kubernetes cluster
|
|
||||||
|
|
||||||
Use "airshipctl [command] --help" for more information about a command.
|
Use "airshipctl [command] --help" for more information about a command.
|
||||||
|
@ -9,4 +9,11 @@ spec:
|
|||||||
bootMACAddress: 00:3b:8b:0c:ec:8b
|
bootMACAddress: 00:3b:8b:0c:ec:8b
|
||||||
bmc:
|
bmc:
|
||||||
address: redfish+http://localhost:8000/redfish/v1/Systems/air-ephemeral
|
address: redfish+http://localhost:8000/redfish/v1/Systems/air-ephemeral
|
||||||
credentialsName: master-0-bmc-secret
|
credentialsName: master-0-bmc-secret
|
||||||
|
status:
|
||||||
|
provisioning:
|
||||||
|
# we need this status to make sure, that the host is not going to be
|
||||||
|
# reprovisioned by the ephemeral baremetal operator.
|
||||||
|
# when we have more flexible labeling system in place, we will not
|
||||||
|
# deliver this document to ephemeral cluster
|
||||||
|
state: externally provisioned
|
101
pkg/cluster/initinfra/infra.go
Normal file
101
pkg/cluster/initinfra/infra.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package initinfra
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||||
|
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||||
|
|
||||||
|
"opendev.org/airship/airshipctl/pkg/config"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/document"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/environment"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/k8s/client"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/k8s/kubectl"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Infra is an abstraction used to initialize base infrastructure
|
||||||
|
type Infra struct {
|
||||||
|
FileSystem fs.FileSystem
|
||||||
|
RootSettings *environment.AirshipCTLSettings
|
||||||
|
Client client.Interface
|
||||||
|
|
||||||
|
DryRun bool
|
||||||
|
Prune bool
|
||||||
|
ClusterType string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInfra return instance of Infra
|
||||||
|
func NewInfra(rs *environment.AirshipCTLSettings) *Infra {
|
||||||
|
// At this point AirshipCTLSettings may not be fully initialized
|
||||||
|
infra := &Infra{RootSettings: rs}
|
||||||
|
return infra
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run intinfra subcommand logic
|
||||||
|
func (infra *Infra) Run() error {
|
||||||
|
infra.FileSystem = kubectl.Buffer{FileSystem: fs.MakeRealFS()}
|
||||||
|
var err error
|
||||||
|
infra.Client, err = client.NewClient(infra.RootSettings)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return infra.Deploy()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deploy method deploys documents
|
||||||
|
func (infra *Infra) Deploy() error {
|
||||||
|
kctl := infra.Client.Kubectl()
|
||||||
|
var err error
|
||||||
|
ao, err := kctl.ApplyOptions()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ao.SetDryRun(infra.DryRun)
|
||||||
|
// If prune is true, set selector for purning
|
||||||
|
if infra.Prune {
|
||||||
|
ao.SetPrune(document.DeployedByLabel + "=" + document.InitinfraIdentifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
globalConf := infra.RootSettings.Config()
|
||||||
|
if err = globalConf.EnsureComplete(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var manifest *config.Manifest
|
||||||
|
manifest, err = globalConf.CurrentContextManifest()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := document.NewBundle(infra.FileSystem, manifest.TargetPath, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
filterSelector := types.Selector{
|
||||||
|
LabelSelector: document.EphemeralClusterSelector,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get documents that are annotated to belong to initinfra
|
||||||
|
docs, err := b.Select(filterSelector)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Label every document indicating that it was deployed by initinfra module for further reference
|
||||||
|
// This may be used later to get all resources that are part of initinfra module, for monitoring, alerting
|
||||||
|
// upgrading etc...
|
||||||
|
// also if prune is set to true, this fulfills requirement for all labeled document to be labeled.
|
||||||
|
// Pruning by annotation is not available, therefore we need to use label.
|
||||||
|
for _, doc := range docs {
|
||||||
|
res := doc.GetKustomizeResource()
|
||||||
|
labels := res.GetLabels()
|
||||||
|
labels[document.DeployedByLabel] = document.InitinfraIdentifier
|
||||||
|
res.SetLabels(labels)
|
||||||
|
err := doc.SetKustomizeResource(&res)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return kctl.Apply(docs, ao)
|
||||||
|
}
|
127
pkg/cluster/initinfra/infra_test.go
Normal file
127
pkg/cluster/initinfra/infra_test.go
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
package initinfra_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
"sigs.k8s.io/kustomize/v3/pkg/fs"
|
||||||
|
|
||||||
|
"opendev.org/airship/airshipctl/pkg/cluster/initinfra"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/document"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/environment"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/k8s/client"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/k8s/kubectl"
|
||||||
|
"opendev.org/airship/airshipctl/testutil/k8sutils"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TestClient struct {
|
||||||
|
MockKubectl func() kubectl.Interface
|
||||||
|
MockClientset func() kubernetes.Interface
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tc TestClient) ClientSet() kubernetes.Interface { return tc.MockClientset() }
|
||||||
|
func (tc TestClient) Kubectl() kubectl.Interface { return tc.MockKubectl() }
|
||||||
|
|
||||||
|
type TestKubectl struct {
|
||||||
|
MockApply func() error
|
||||||
|
MockApplyOptions func() (*kubectl.ApplyOptions, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tk TestKubectl) Apply(docs []document.Document, ao *kubectl.ApplyOptions) error {
|
||||||
|
return tk.MockApply()
|
||||||
|
}
|
||||||
|
func (tk TestKubectl) ApplyOptions() (*kubectl.ApplyOptions, error) {
|
||||||
|
return tk.MockApplyOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
kubeconfigPath = "testdata/kubeconfig.yaml"
|
||||||
|
filenameRC = "testdata/replicationcontroller.yaml"
|
||||||
|
airshipConfigFile = "testdata/config.yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
DynamicClientError = errors.New("DynamicClientError")
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewInfra(t *testing.T) {
|
||||||
|
rs := makeNewFakeRootSettings(t, kubeconfigPath, airshipConfigFile)
|
||||||
|
infra := initinfra.NewInfra(rs)
|
||||||
|
|
||||||
|
assert.NotNil(t, infra.RootSettings)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeploy(t *testing.T) {
|
||||||
|
rs := makeNewFakeRootSettings(t, kubeconfigPath, airshipConfigFile)
|
||||||
|
tf := k8sutils.NewFakeFactoryForRC(t, filenameRC)
|
||||||
|
defer tf.Cleanup()
|
||||||
|
|
||||||
|
infra := initinfra.NewInfra(rs)
|
||||||
|
infra.ClusterType = "ephemeral"
|
||||||
|
infra.DryRun = true
|
||||||
|
|
||||||
|
infra.FileSystem = kubectl.Buffer{FileSystem: fs.MakeRealFS()}
|
||||||
|
|
||||||
|
kctl := kubectl.NewKubectl(tf)
|
||||||
|
tc := TestClient{
|
||||||
|
MockKubectl: func() kubectl.Interface { return kctl },
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
theInfra *initinfra.Infra
|
||||||
|
client client.Interface
|
||||||
|
prune bool
|
||||||
|
expectedError error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
client: TestClient{
|
||||||
|
MockKubectl: func() kubectl.Interface {
|
||||||
|
return kubectl.NewKubectl(k8sutils.
|
||||||
|
NewMockKubectlFactory().
|
||||||
|
WithDynamicClientByError(nil, DynamicClientError))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedError: DynamicClientError,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
expectedError: nil,
|
||||||
|
prune: false,
|
||||||
|
client: tc,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
expectedError: nil,
|
||||||
|
prune: true,
|
||||||
|
client: tc,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
infra.Prune = test.prune
|
||||||
|
infra.Client = test.client
|
||||||
|
actualErr := infra.Deploy()
|
||||||
|
assert.Equal(t, test.expectedError, actualErr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakeNewFakeRootSettings takes kubeconfig path and directory path to fixture dir as argument.
|
||||||
|
func makeNewFakeRootSettings(t *testing.T, kp string, dir string) *environment.AirshipCTLSettings {
|
||||||
|
t.Helper()
|
||||||
|
rs := &environment.AirshipCTLSettings{}
|
||||||
|
|
||||||
|
akp, err := filepath.Abs(kp)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
adir, err := filepath.Abs(dir)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
rs.SetAirshipConfigPath(adir)
|
||||||
|
rs.SetKubeConfigPath(akp)
|
||||||
|
|
||||||
|
rs.InitConfig()
|
||||||
|
return rs
|
||||||
|
}
|
43
pkg/cluster/initinfra/testdata/config.yaml
vendored
Normal file
43
pkg/cluster/initinfra/testdata/config.yaml
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
clusters:
|
||||||
|
dummycluster:
|
||||||
|
cluster-type:
|
||||||
|
ephemeral:
|
||||||
|
bootstrap-info: dummy_bootstrap_config
|
||||||
|
cluster-kubeconf: dummycluster_ephemeral
|
||||||
|
contexts:
|
||||||
|
dummy_cluster:
|
||||||
|
context-kubeconf: dummy_cluster
|
||||||
|
manifest: dummy_manifest
|
||||||
|
current-context: dummy_cluster
|
||||||
|
kind: Config
|
||||||
|
manifests:
|
||||||
|
dummy_manifest:
|
||||||
|
repositories:
|
||||||
|
dummy:
|
||||||
|
target-path: dummy_targetpath
|
||||||
|
url:
|
||||||
|
ForceQuery: false
|
||||||
|
Fragment: ""
|
||||||
|
Host: dummy.url.com
|
||||||
|
Opaque: ""
|
||||||
|
Path: ""
|
||||||
|
RawPath: ""
|
||||||
|
RawQuery: ""
|
||||||
|
Scheme: http
|
||||||
|
User: null
|
||||||
|
username: dummy_user
|
||||||
|
target-path: testdata
|
||||||
|
modules-config:
|
||||||
|
bootstrapInfo:
|
||||||
|
dummy_bootstrap_config:
|
||||||
|
container:
|
||||||
|
volume: /tmp/airship:/config
|
||||||
|
image: quay.io/airshipit/isogen:latest
|
||||||
|
containerRuntime: docker
|
||||||
|
builder:
|
||||||
|
userDataFileName: user-data
|
||||||
|
networkConfigFileName: network-config
|
||||||
|
outputMetadataFileName: output-metadata.yaml
|
||||||
|
users:
|
||||||
|
dummy_user: {}
|
19
pkg/cluster/initinfra/testdata/kubeconfig.yaml
vendored
Normal file
19
pkg/cluster/initinfra/testdata/kubeconfig.yaml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
clusters:
|
||||||
|
- cluster:
|
||||||
|
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFNU1Ea3lPVEUzTURNd09Wb1hEVEk1TURreU5qRTNNRE13T1Zvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTUZyCkdxM0kyb2dZci81Y01Udy9Na1pORTNW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.0.0.1:6443
|
||||||
|
name: dummycluster_ephemeral
|
||||||
|
contexts:
|
||||||
|
- context:
|
||||||
|
cluster: dummycluster_ephemeral
|
||||||
|
user: kubernetes-admin
|
||||||
|
name: dummy_cluster
|
||||||
|
current-context: dummy_cluster
|
||||||
|
kind: Config
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
- name: kubernetes-admin
|
||||||
|
user:
|
||||||
|
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQXhEdzk2RUY4SXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBNU1qa3hOekF6TURsYUZ3MHlNREE1TWpneE56QXpNVEphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXV6R0pZdlBaNkRvaTQyMUQKSzhXSmFaQ25OQWQycXo1cC8wNDJvRnpRUGJyQWd6RTJxWVZrek9MOHhBVmVSN1NONXdXb1RXRXlGOEVWN3JyLwo0K0hoSEdpcTVQbXF1SUZ5enpuNi9JWmM4alU5eEVmenZpa2NpckxmVTR2UlhKUXdWd2dBU05sMkFXQUloMmRECmRUcmpCQ2ZpS1dNSHlqMFJiSGFsc0J6T3BnVC9IVHYzR1F6blVRekZLdjJkajVWMU5rUy9ESGp5UlJKK0VMNlEKQlltR3NlZzVQNE5iQzllYnVpcG1NVEFxL0p1bU9vb2QrRmpMMm5acUw2Zkk2ZkJ0RjVPR2xwQ0IxWUo4ZnpDdApHUVFaN0hUSWJkYjJ0cDQzRlZPaHlRYlZjSHFUQTA0UEoxNSswV0F5bVVKVXo4WEE1NDRyL2J2NzRKY0pVUkZoCmFyWmlR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3g5c1pONVJCbG9VRThZNGJBb0dBQ3ZsdVhMZWRxcng5VkE0bDNoNXUKVDJXRVUxYjgxZ1orcmtRc1I1S0lNWEw4cllBTElUNUpHKzFuendyN3BkaEFXZmFWdVV2SDRhamdYT0h6MUs5aQpFODNSVTNGMG9ldUg0V01PY1RwU0prWm0xZUlXcWRiaEVCb1FGdUlWTXRib1BsV0d4ZUhFRHJoOEtreGp4aThSCmdEcUQyajRwY1IzQ0g5QjJ5a0lqQjVFQ2dZRUExc0xXLys2enE1c1lNSm14K1JXZThhTXJmL3pjQnVTSU1LQWgKY0dNK0wwMG9RSHdDaUU4TVNqcVN1ajV3R214YUFuanhMb3ZwSFlRV1VmUEVaUW95UE1YQ2VhRVBLOU4xbk8xMwp0V2lHRytIZkIxaU5PazFCc0lhNFNDbndOM1FRVTFzeXBaeEgxT3hueS9LYmkvYmEvWEZ5VzNqMGFUK2YvVWxrCmJGV1ZVdWtDZ1lFQTBaMmRTTFlmTjV5eFNtYk5xMWVqZXdWd1BjRzQxR2hQclNUZEJxdHFac1doWGE3aDdLTWEKeHdvamh5SXpnTXNyK2tXODdlajhDQ2h0d21sQ1p5QU92QmdOZytncnJ1cEZLM3FOSkpKeU9YREdHckdpbzZmTQp5aXB3Q2tZVGVxRThpZ1J6UkI5QkdFUGY4eVpjMUtwdmZhUDVhM0lRZmxiV0czbGpUemNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
|
2
pkg/cluster/initinfra/testdata/kustomization.yaml
vendored
Normal file
2
pkg/cluster/initinfra/testdata/kustomization.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
resources:
|
||||||
|
- replicationcontroller.yaml
|
21
pkg/cluster/initinfra/testdata/replicationcontroller.yaml
vendored
Normal file
21
pkg/cluster/initinfra/testdata/replicationcontroller.yaml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ReplicationController
|
||||||
|
metadata:
|
||||||
|
name: test-rc
|
||||||
|
namespace: test
|
||||||
|
labels:
|
||||||
|
airshipit.org/ephemeral: "true"
|
||||||
|
name: test-rc
|
||||||
|
airship-component: "initinfra"
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: test-rc
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: test-rc
|
||||||
|
image: nginx
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
@ -2,7 +2,14 @@ package document
|
|||||||
|
|
||||||
// Document labels and annotations
|
// Document labels and annotations
|
||||||
const (
|
const (
|
||||||
|
// Selectors
|
||||||
BaseAirshipSelector = "airshipit.org"
|
BaseAirshipSelector = "airshipit.org"
|
||||||
EphemeralClusterSelector = BaseAirshipSelector + "/ephemeral in (True, true)"
|
EphemeralClusterSelector = BaseAirshipSelector + "/ephemeral in (True, true)"
|
||||||
TargetClusterSelector = BaseAirshipSelector + "/target in (True, true)"
|
TargetClusterSelector = BaseAirshipSelector + "/target in (True, true)"
|
||||||
|
|
||||||
|
// Labels
|
||||||
|
DeployedByLabel = BaseAirshipSelector + "/deployed"
|
||||||
|
|
||||||
|
// Identifiers (Static label values)
|
||||||
|
InitinfraIdentifier = "initinfra"
|
||||||
)
|
)
|
||||||
|
42
testdata/k8s/config.yaml
vendored
Normal file
42
testdata/k8s/config.yaml
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
clusters:
|
||||||
|
default:
|
||||||
|
cluster-type:
|
||||||
|
target:
|
||||||
|
bootstrap-info: ""
|
||||||
|
cluster-kubeconf: default_target
|
||||||
|
kubernetes:
|
||||||
|
cluster-type: {}
|
||||||
|
contexts:
|
||||||
|
default:
|
||||||
|
context-kubeconf: default_target
|
||||||
|
manifest: default
|
||||||
|
current-context: ""
|
||||||
|
kind: Config
|
||||||
|
manifests:
|
||||||
|
default:
|
||||||
|
repository:
|
||||||
|
checkout:
|
||||||
|
branch: master
|
||||||
|
commit-hash: master
|
||||||
|
force: false
|
||||||
|
remote-ref: master
|
||||||
|
tag: ""
|
||||||
|
url: https://opendev.org/airship/treasuremap
|
||||||
|
target-path: /tmp/default
|
||||||
|
modules-config:
|
||||||
|
bootstrapInfo:
|
||||||
|
default:
|
||||||
|
builder:
|
||||||
|
networkConfigFileName: network-config
|
||||||
|
outputMetadataFileName: output-metadata.yaml
|
||||||
|
userDataFileName: user-data
|
||||||
|
container:
|
||||||
|
containerRuntime: docker
|
||||||
|
image: quay.io/airshipit/isogen:latest
|
||||||
|
volume: /srv/iso:/config
|
||||||
|
remoteDirect:
|
||||||
|
isoUrl: http://localhost:8099/debian-custom.iso
|
||||||
|
remoteType: redfish
|
||||||
|
users:
|
||||||
|
admin: {}
|
17
testdata/k8s/kubeconfig.yaml
vendored
Normal file
17
testdata/k8s/kubeconfig.yaml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
clusters:
|
||||||
|
- cluster:
|
||||||
|
server: https://172.17.0.1:6443
|
||||||
|
name: default_target
|
||||||
|
contexts:
|
||||||
|
- context:
|
||||||
|
cluster: default_target
|
||||||
|
user: admin
|
||||||
|
name: default
|
||||||
|
current-context: ""
|
||||||
|
kind: Config
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
- name: admin
|
||||||
|
user:
|
||||||
|
username: airship-admin
|
Loading…
Reference in New Issue
Block a user