forked from LaconicNetwork/kompose
Merge branch 'main' into feature-1846-network_mode-service
Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
This commit is contained in:
commit
3c189aaff1
@ -62,7 +62,7 @@ var (
|
|||||||
// default is true.
|
// default is true.
|
||||||
WithKomposeAnnotation bool
|
WithKomposeAnnotation bool
|
||||||
|
|
||||||
// MultipleContainerMode which enables creating multi containers in a single pod is a developping function.
|
// MultipleContainerMode which enables creating multi containers in a single pod is a developing function.
|
||||||
// default is false
|
// default is false
|
||||||
MultipleContainerMode bool
|
MultipleContainerMode bool
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ var RootCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute executes the root level command.
|
// Execute executes the root level command.
|
||||||
// It returns an erorr if any.
|
// It returns an error if any.
|
||||||
func Execute() error {
|
func Execute() error {
|
||||||
return RootCmd.Execute()
|
return RootCmd.Execute()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -465,7 +465,7 @@ func dockerComposeToKomposeMapping(composeObject *types.Project) (kobject.Kompos
|
|||||||
for _, composeServiceConfig := range composeObject.Services {
|
for _, composeServiceConfig := range composeObject.Services {
|
||||||
// Standard import
|
// Standard import
|
||||||
// No need to modify before importation
|
// No need to modify before importation
|
||||||
name := strings.ToLower(composeServiceConfig.Name)
|
name := parseResourceName(composeServiceConfig.Name, composeServiceConfig.Labels)
|
||||||
serviceConfig := kobject.ServiceConfig{}
|
serviceConfig := kobject.ServiceConfig{}
|
||||||
serviceConfig.Name = name
|
serviceConfig.Name = name
|
||||||
serviceConfig.Image = composeServiceConfig.Image
|
serviceConfig.Image = composeServiceConfig.Image
|
||||||
@ -802,6 +802,10 @@ func parseKomposeLabels(labels map[string]string, serviceConfig *kobject.Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
serviceConfig.CronJobBackoffLimit = cronJobBackoffLimit
|
serviceConfig.CronJobBackoffLimit = cronJobBackoffLimit
|
||||||
|
case LabelNameOverride:
|
||||||
|
// generate a valid k8s resource name
|
||||||
|
normalizedName := normalizeServiceNames(value)
|
||||||
|
serviceConfig.Name = normalizedName
|
||||||
default:
|
default:
|
||||||
serviceConfig.Labels[key] = value
|
serviceConfig.Labels[key] = value
|
||||||
}
|
}
|
||||||
|
|||||||
@ -647,3 +647,113 @@ func checkConstraints(t *testing.T, caseName string, output, expected map[string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_parseKomposeLabels(t *testing.T) {
|
||||||
|
service := kobject.ServiceConfig{
|
||||||
|
Name: "name",
|
||||||
|
ContainerName: "containername",
|
||||||
|
Image: "image",
|
||||||
|
Labels: nil,
|
||||||
|
Annotations: map[string]string{"abc": "def"},
|
||||||
|
Restart: "always",
|
||||||
|
}
|
||||||
|
|
||||||
|
type args struct {
|
||||||
|
labels types.Labels
|
||||||
|
serviceConfig *kobject.ServiceConfig
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
expected *kobject.ServiceConfig
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "override with overriding",
|
||||||
|
args: args{
|
||||||
|
labels: types.Labels{
|
||||||
|
LabelNameOverride: "overriding",
|
||||||
|
},
|
||||||
|
serviceConfig: &service,
|
||||||
|
},
|
||||||
|
expected: &kobject.ServiceConfig{
|
||||||
|
Name: "overriding",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "override",
|
||||||
|
args: args{
|
||||||
|
labels: types.Labels{
|
||||||
|
LabelNameOverride: "overriding-resource-name",
|
||||||
|
},
|
||||||
|
serviceConfig: &service,
|
||||||
|
},
|
||||||
|
expected: &kobject.ServiceConfig{
|
||||||
|
Name: "overriding-resource-name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "hyphen in the middle",
|
||||||
|
args: args{
|
||||||
|
labels: types.Labels{
|
||||||
|
LabelNameOverride: "overriding_resource-name",
|
||||||
|
},
|
||||||
|
serviceConfig: &service,
|
||||||
|
},
|
||||||
|
expected: &kobject.ServiceConfig{
|
||||||
|
Name: "overriding-resource-name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "hyphen in the middle with mays",
|
||||||
|
args: args{
|
||||||
|
labels: types.Labels{
|
||||||
|
LabelNameOverride: "OVERRIDING_RESOURCE-NAME",
|
||||||
|
},
|
||||||
|
serviceConfig: &service,
|
||||||
|
},
|
||||||
|
expected: &kobject.ServiceConfig{
|
||||||
|
Name: "overriding-resource-name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// This is a corner case that is expected to fail because
|
||||||
|
// it does not account for scenarios where the string
|
||||||
|
// starts or ends with a '-' or any other character
|
||||||
|
// this test will fail with current tests
|
||||||
|
// {
|
||||||
|
// name: "Add a prefix with a dash at the start and end, with a hyphen in the middle.",
|
||||||
|
// args: args{
|
||||||
|
// labels: types.Labels{
|
||||||
|
// LabelNameOverride: "-OVERRIDING_RESOURCE-NAME-",
|
||||||
|
// },
|
||||||
|
// serviceConfig: &service,
|
||||||
|
// },
|
||||||
|
// expected: &kobject.ServiceConfig{
|
||||||
|
// Name: "overriding-resource-name",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// not fail
|
||||||
|
{
|
||||||
|
name: "Add a prefix with a dash at the start and end, with a hyphen in the middle.",
|
||||||
|
args: args{
|
||||||
|
labels: types.Labels{
|
||||||
|
LabelNameOverride: "-OVERRIDING_RESOURCE-NAME-",
|
||||||
|
},
|
||||||
|
serviceConfig: &service,
|
||||||
|
},
|
||||||
|
expected: &kobject.ServiceConfig{
|
||||||
|
Name: "-overriding-resource-name-",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if err := parseKomposeLabels(tt.args.labels, tt.args.serviceConfig); err != nil {
|
||||||
|
t.Errorf("parseKomposeLabels(): %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if tt.expected.Name != tt.args.serviceConfig.Name {
|
||||||
|
t.Errorf("Name are not equal, expected: %v, output: %v", tt.expected.Name, tt.args.serviceConfig.Name)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
"github.com/kubernetes/kompose/pkg/kobject"
|
"github.com/kubernetes/kompose/pkg/kobject"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@ -101,6 +102,8 @@ const (
|
|||||||
LabelHpaCPU = "kompose.hpa.cpu"
|
LabelHpaCPU = "kompose.hpa.cpu"
|
||||||
// LabelHpaMemory defines scaling decisions based on memory utilization
|
// LabelHpaMemory defines scaling decisions based on memory utilization
|
||||||
LabelHpaMemory = "kompose.hpa.memory"
|
LabelHpaMemory = "kompose.hpa.memory"
|
||||||
|
// LabelNameOverride defines the override resource name
|
||||||
|
LabelNameOverride = "kompose.service.name_override"
|
||||||
)
|
)
|
||||||
|
|
||||||
// load environment variables from compose file
|
// load environment variables from compose file
|
||||||
@ -208,3 +211,15 @@ func ReadFile(fileName string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
return os.ReadFile(fileName)
|
return os.ReadFile(fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Choose normalized name from resource in case exist LabelNameOverride
|
||||||
|
// from label
|
||||||
|
func parseResourceName(resourceName string, labels types.Labels) string {
|
||||||
|
// Opted to use normalizeContainerNames over normalizeServiceNames
|
||||||
|
// as in tests, normalization is only to lowercase.
|
||||||
|
normalizedName := normalizeContainerNames(resourceName)
|
||||||
|
if labelValue, exist := labels[LabelNameOverride]; exist {
|
||||||
|
normalizedName = normalizeContainerNames(labelValue)
|
||||||
|
}
|
||||||
|
return normalizedName
|
||||||
|
}
|
||||||
|
|||||||
@ -1183,6 +1183,84 @@ func getHpaMetricSpec(hpaValues HpaValues) []hpa.MetricSpec {
|
|||||||
return metrics
|
return metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isConfigFile checks if the given filePath should be used as a configMap
|
||||||
|
// if dir is not empty, withindir are treated as cofigmaps
|
||||||
|
// if it's configMap, mount readonly as default
|
||||||
|
func isConfigFile(filePath string) (useConfigMap bool, readonly bool, skip bool) {
|
||||||
|
if filePath == "" || strings.HasSuffix(filePath, ".sock") {
|
||||||
|
skip = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fi, err := os.Stat(filePath)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("File don't exist or failed to check if the directory is empty: %v", err)
|
||||||
|
// dir/file not exist
|
||||||
|
// here not assigned skip to true,
|
||||||
|
// maybe dont want to skip
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !fi.Mode().IsRegular() { // is dir
|
||||||
|
isDirEmpty, err := checkIsEmptyDir(filePath)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to check if the directory is empty: %v", err)
|
||||||
|
skip = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if isDirEmpty {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true, true, skip
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkIsEmptyDir checks if filepath is empty
|
||||||
|
func checkIsEmptyDir(filePath string) (bool, error) {
|
||||||
|
files, err := os.ReadDir(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if len(files) == 0 {
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
for _, file := range files {
|
||||||
|
if !file.IsDir() {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
_, err := checkIsEmptyDir(file.Name())
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// setVolumeAccessMode sets the access mode for a volume based on the mode string
|
||||||
|
// current types:
|
||||||
|
// ReadOnly RO and ReadOnlyMany ROX can be mounted in read-only mode to many hosts
|
||||||
|
// ReadWriteMany RWX can be mounted in read/write mode to many hosts
|
||||||
|
// ReadWriteOncePod RWOP can be mounted in read/write mode to exactly 1 pod
|
||||||
|
// ReadWriteOnce RWO can be mounted in read/write mode to exactly 1 host
|
||||||
|
// https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
|
||||||
|
func setVolumeAccessMode(mode string, volumeAccesMode []api.PersistentVolumeAccessMode) []api.PersistentVolumeAccessMode {
|
||||||
|
switch mode {
|
||||||
|
case "ro", "rox":
|
||||||
|
volumeAccesMode = []api.PersistentVolumeAccessMode{api.ReadOnlyMany}
|
||||||
|
case "rwx":
|
||||||
|
volumeAccesMode = []api.PersistentVolumeAccessMode{api.ReadWriteMany}
|
||||||
|
case "rwop":
|
||||||
|
volumeAccesMode = []api.PersistentVolumeAccessMode{api.ReadWriteOncePod}
|
||||||
|
case "rwo":
|
||||||
|
volumeAccesMode = []api.PersistentVolumeAccessMode{api.ReadWriteOnce}
|
||||||
|
default:
|
||||||
|
volumeAccesMode = []api.PersistentVolumeAccessMode{api.ReadWriteOnce}
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumeAccesMode
|
||||||
|
}
|
||||||
|
|
||||||
// fixNetworkModeToService is responsible for adjusting the network mode of services in docker compose (services:)
|
// fixNetworkModeToService is responsible for adjusting the network mode of services in docker compose (services:)
|
||||||
// generate a mapping of deployments based on the network mode of each service
|
// generate a mapping of deployments based on the network mode of each service
|
||||||
// merging containers into the destination deployment, and removing transferred deployments
|
// merging containers into the destination deployment, and removing transferred deployments
|
||||||
|
|||||||
@ -2224,6 +2224,224 @@ func Test_createHPAResources(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_setVolumeAccessMode(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
mode string
|
||||||
|
volumeAccesMode []api.PersistentVolumeAccessMode
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want []api.PersistentVolumeAccessMode
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "readonly",
|
||||||
|
args: args{
|
||||||
|
mode: "ro",
|
||||||
|
volumeAccesMode: []api.PersistentVolumeAccessMode{},
|
||||||
|
},
|
||||||
|
want: []api.PersistentVolumeAccessMode{api.ReadOnlyMany},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "not acceptable",
|
||||||
|
args: args{
|
||||||
|
mode: "wrong",
|
||||||
|
volumeAccesMode: []api.PersistentVolumeAccessMode{},
|
||||||
|
},
|
||||||
|
want: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "readonly many",
|
||||||
|
args: args{
|
||||||
|
mode: "rox",
|
||||||
|
volumeAccesMode: []api.PersistentVolumeAccessMode{},
|
||||||
|
},
|
||||||
|
want: []api.PersistentVolumeAccessMode{api.ReadOnlyMany},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "readwrite many",
|
||||||
|
args: args{
|
||||||
|
mode: "rwx",
|
||||||
|
volumeAccesMode: []api.PersistentVolumeAccessMode{},
|
||||||
|
},
|
||||||
|
want: []api.PersistentVolumeAccessMode{api.ReadWriteMany},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "readwrite once in pod",
|
||||||
|
args: args{
|
||||||
|
mode: "rwop",
|
||||||
|
volumeAccesMode: []api.PersistentVolumeAccessMode{},
|
||||||
|
},
|
||||||
|
want: []api.PersistentVolumeAccessMode{api.ReadWriteOncePod},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "readwrite once",
|
||||||
|
args: args{
|
||||||
|
mode: "rwo",
|
||||||
|
volumeAccesMode: []api.PersistentVolumeAccessMode{},
|
||||||
|
},
|
||||||
|
want: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := setVolumeAccessMode(tt.args.mode, tt.args.volumeAccesMode); !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("setVolumeAccessMode() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_isConfigFile(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
filePath string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
wantUseConfigMap bool
|
||||||
|
wantReadonly bool
|
||||||
|
wantSkip bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "dir not empty",
|
||||||
|
args: args{
|
||||||
|
filePath: "../../../script/test/fixtures/configmap-file-configs/certs",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: true,
|
||||||
|
wantReadonly: true,
|
||||||
|
wantSkip: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "sock",
|
||||||
|
args: args{
|
||||||
|
filePath: "./docker.sock",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: false,
|
||||||
|
wantReadonly: false,
|
||||||
|
wantSkip: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "cannot resolve filepath",
|
||||||
|
args: args{
|
||||||
|
filePath: "./certs/cert1.pem",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: false,
|
||||||
|
wantReadonly: false,
|
||||||
|
wantSkip: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "file cert",
|
||||||
|
args: args{
|
||||||
|
filePath: "../../../script/test/fixtures/configmap-file-configs/certs/cert1.pem",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: true,
|
||||||
|
wantReadonly: true,
|
||||||
|
wantSkip: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "docker sock",
|
||||||
|
args: args{
|
||||||
|
filePath: "/var/run/docker.sock",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: false,
|
||||||
|
wantReadonly: false,
|
||||||
|
wantSkip: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "dir sys",
|
||||||
|
args: args{
|
||||||
|
filePath: "/sys",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: false,
|
||||||
|
wantReadonly: false,
|
||||||
|
wantSkip: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "dir root",
|
||||||
|
args: args{
|
||||||
|
filePath: "/root",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: false,
|
||||||
|
wantReadonly: false,
|
||||||
|
wantSkip: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "docker var lib",
|
||||||
|
args: args{
|
||||||
|
filePath: "/var/lib/docker",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: false,
|
||||||
|
wantReadonly: false,
|
||||||
|
wantSkip: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "file from 3 levels",
|
||||||
|
args: args{
|
||||||
|
filePath: "../../../script/test/fixtures/configmap-file-configs/certs-level1/certs-level2/certs-level3/cert2.pem",
|
||||||
|
},
|
||||||
|
wantUseConfigMap: true,
|
||||||
|
wantReadonly: true,
|
||||||
|
wantSkip: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
gotUseConfigMap, gotReadonly, gotSkip := isConfigFile(tt.args.filePath)
|
||||||
|
if gotUseConfigMap != tt.wantUseConfigMap {
|
||||||
|
t.Errorf("isConfigFile() gotUseConfigMap = %v, want %v", gotUseConfigMap, tt.wantUseConfigMap)
|
||||||
|
}
|
||||||
|
if gotReadonly != tt.wantReadonly {
|
||||||
|
t.Errorf("isConfigFile() gotReadonly = %v, want %v", gotReadonly, tt.wantReadonly)
|
||||||
|
}
|
||||||
|
if gotSkip != tt.wantSkip {
|
||||||
|
t.Errorf("isConfigFile() gotSkip = %v, want %v", gotSkip, tt.wantSkip)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_checkIsEmptyDir(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
filePath string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want bool
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "dir not found",
|
||||||
|
args: args{
|
||||||
|
filePath: "../../../script/test/fixtures/configmap-file-configs/notfound",
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "dir not empty",
|
||||||
|
args: args{
|
||||||
|
filePath: "../../../script/test/fixtures/configmap-file-configs/certs",
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got, err := checkIsEmptyDir(tt.args.filePath)
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("checkIsEmptyDir() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if got != tt.want {
|
||||||
|
t.Errorf("checkIsEmptyDir() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Test_removeFromSlice(t *testing.T) {
|
func Test_removeFromSlice(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
objects []runtime.Object
|
objects []runtime.Object
|
||||||
|
|||||||
@ -635,11 +635,7 @@ func (k *Kubernetes) CreatePVC(name string, mode string, size string, selectorVa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if mode == "ro" {
|
pvc.Spec.AccessModes = setVolumeAccessMode(mode, pvc.Spec.AccessModes)
|
||||||
pvc.Spec.AccessModes = []api.PersistentVolumeAccessMode{api.ReadOnlyMany}
|
|
||||||
} else {
|
|
||||||
pvc.Spec.AccessModes = []api.PersistentVolumeAccessMode{api.ReadWriteOnce}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(storageClassName) > 0 {
|
if len(storageClassName) > 0 {
|
||||||
pvc.Spec.StorageClassName = &storageClassName
|
pvc.Spec.StorageClassName = &storageClassName
|
||||||
@ -955,10 +951,22 @@ func (k *Kubernetes) ConfigVolumes(name string, service kobject.ServiceConfig) (
|
|||||||
volumes = append(volumes, secretsVolumes...)
|
volumes = append(volumes, secretsVolumes...)
|
||||||
|
|
||||||
var count int
|
var count int
|
||||||
|
skip := false
|
||||||
//iterating over array of `Vols` struct as it contains all necessary information about volumes
|
//iterating over array of `Vols` struct as it contains all necessary information about volumes
|
||||||
for _, volume := range service.Volumes {
|
for _, volume := range service.Volumes {
|
||||||
// check if ro/rw mode is defined, default rw
|
// check if ro/rw mode is defined, default rw
|
||||||
readonly := len(volume.Mode) > 0 && volume.Mode == "ro"
|
readonly := len(volume.Mode) > 0 && (volume.Mode == "ro" || volume.Mode == "rox")
|
||||||
|
mountHost := volume.Host
|
||||||
|
if mountHost == "" {
|
||||||
|
mountHost = volume.MountPath
|
||||||
|
}
|
||||||
|
// return useconfigmap and readonly,
|
||||||
|
// not used asigned readonly because dont break e2e
|
||||||
|
useConfigMap, _, skip = isConfigFile(mountHost)
|
||||||
|
if skip {
|
||||||
|
log.Warnf("Skip file in path %s ", volume.Host)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if volume.VolumeName == "" {
|
if volume.VolumeName == "" {
|
||||||
if useEmptyVolumes {
|
if useEmptyVolumes {
|
||||||
volumeName = strings.Replace(volume.PVCName, "claim", "empty", 1)
|
volumeName = strings.Replace(volume.PVCName, "claim", "empty", 1)
|
||||||
|
|||||||
@ -327,7 +327,7 @@ func TestKomposeConvert(t *testing.T) {
|
|||||||
opt kobject.ConvertOptions
|
opt kobject.ConvertOptions
|
||||||
expectedNumObjs int
|
expectedNumObjs int
|
||||||
}{
|
}{
|
||||||
// objects generated are deployment, service nework policies (2) and pvc
|
// objects generated are deployment, service network policies (2) and pvc
|
||||||
"Convert to Deployments (D)": {newKomposeObject(), kobject.ConvertOptions{CreateD: true, Replicas: replicas, IsReplicaSetFlag: true}, 4},
|
"Convert to Deployments (D)": {newKomposeObject(), kobject.ConvertOptions{CreateD: true, Replicas: replicas, IsReplicaSetFlag: true}, 4},
|
||||||
"Convert to Deployments (D) with v3 replicas": {newKomposeObject(), kobject.ConvertOptions{CreateD: true}, 4},
|
"Convert to Deployments (D) with v3 replicas": {newKomposeObject(), kobject.ConvertOptions{CreateD: true}, 4},
|
||||||
"Convert to DaemonSets (DS)": {newKomposeObject(), kobject.ConvertOptions{CreateDS: true}, 4},
|
"Convert to DaemonSets (DS)": {newKomposeObject(), kobject.ConvertOptions{CreateDS: true}, 4},
|
||||||
@ -757,7 +757,7 @@ func TestMultipleContainersInPod(t *testing.T) {
|
|||||||
config.Volumes = []kobject.Volumes{
|
config.Volumes = []kobject.Volumes{
|
||||||
{
|
{
|
||||||
VolumeName: "mountVolume",
|
VolumeName: "mountVolume",
|
||||||
MountPath: "/data",
|
MountPath: "/data-dir",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
|
|||||||
@ -350,6 +350,30 @@ k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/hpa/compose.yaml convert
|
|||||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/hpa/output-k8s.yaml"
|
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/hpa/output-k8s.yaml"
|
||||||
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
|
|
||||||
|
#Test auto configmaps from files/dir
|
||||||
|
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-1.yaml convert --stdout --with-kompose-annotation=false"
|
||||||
|
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-1.yaml"
|
||||||
|
os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-1.yaml convert --provider openshift --stdout --with-kompose-annotation=false"
|
||||||
|
os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-1.yaml"
|
||||||
|
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
|
convert::expect_success "$os_cmd" "$os_output" || exit 1
|
||||||
|
|
||||||
|
#Test auto configmaps from files/dir
|
||||||
|
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-2.yaml convert --stdout --with-kompose-annotation=false"
|
||||||
|
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-2.yaml"
|
||||||
|
os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-2.yaml convert --provider openshift --stdout --with-kompose-annotation=false"
|
||||||
|
os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-2.yaml"
|
||||||
|
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
|
convert::expect_success "$os_cmd" "$os_output" || exit 1
|
||||||
|
|
||||||
|
#Test auto configmaps from files/dir
|
||||||
|
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-3.yaml convert --stdout --with-kompose-annotation=false"
|
||||||
|
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-3.yaml"
|
||||||
|
os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-3.yaml convert --provider openshift --stdout --with-kompose-annotation=false"
|
||||||
|
os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-3.yaml"
|
||||||
|
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
|
convert::expect_success "$os_cmd" "$os_output" || exit 1
|
||||||
|
|
||||||
# Test network_mode: service:
|
# Test network_mode: service:
|
||||||
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network-mode-service/compose.yaml convert --stdout --with-kompose-annotation=false"
|
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network-mode-service/compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/network-mode-service/output-k8s.yaml"
|
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/network-mode-service/output-k8s.yaml"
|
||||||
|
|||||||
1
script/test/fixtures/configmap-file-configs/auth.txt
vendored
Normal file
1
script/test/fixtures/configmap-file-configs/auth.txt
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
content from file auth.txt
|
||||||
1
script/test/fixtures/configmap-file-configs/certs-level1/certs-level2/certs-level3/cert2.pem
vendored
Normal file
1
script/test/fixtures/configmap-file-configs/certs-level1/certs-level2/certs-level3/cert2.pem
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
content from file cert2.pem
|
||||||
1
script/test/fixtures/configmap-file-configs/certs/cert1.pem
vendored
Normal file
1
script/test/fixtures/configmap-file-configs/certs/cert1.pem
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
content of file cert1.pem
|
||||||
16
script/test/fixtures/configmap-file-configs/compose-1.yaml
vendored
Normal file
16
script/test/fixtures/configmap-file-configs/compose-1.yaml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
services:
|
||||||
|
busy:
|
||||||
|
image: busybox
|
||||||
|
ports:
|
||||||
|
- "8081:8080"
|
||||||
|
- "8026:8025"
|
||||||
|
volumes:
|
||||||
|
- ./certs:/certs
|
||||||
|
- ./auth.txt:/auth.txt
|
||||||
|
- ./users.php:/users.php:ro
|
||||||
|
command:
|
||||||
|
[
|
||||||
|
"/bin/sh",
|
||||||
|
"-c",
|
||||||
|
"cat /auth.txt /users.php /certs/cert1.pem"
|
||||||
|
]
|
||||||
17
script/test/fixtures/configmap-file-configs/compose-2.yaml
vendored
Normal file
17
script/test/fixtures/configmap-file-configs/compose-2.yaml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
services:
|
||||||
|
busy:
|
||||||
|
image: busybox
|
||||||
|
ports:
|
||||||
|
- "8081:8080"
|
||||||
|
- "8026:8025"
|
||||||
|
volumes:
|
||||||
|
- ./certs:/certs
|
||||||
|
- ./certs-level1/certs-level2/certs-level3/cert2.pem:/certs/cert2.pem
|
||||||
|
- ./auth.txt:/auth.txt
|
||||||
|
- ./users.php:/users.php:ro
|
||||||
|
command:
|
||||||
|
[
|
||||||
|
"/bin/sh",
|
||||||
|
"-c",
|
||||||
|
"cat /auth.txt /users.php /certs/cert1.pem /certs/cert2.pem"
|
||||||
|
]
|
||||||
10
script/test/fixtures/configmap-file-configs/compose-3.yaml
vendored
Normal file
10
script/test/fixtures/configmap-file-configs/compose-3.yaml
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
services:
|
||||||
|
busy:
|
||||||
|
image: busybox
|
||||||
|
ports:
|
||||||
|
- "8081:8080"
|
||||||
|
- "8026:8025"
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
- /sys:/sys:ro
|
||||||
|
- /var/lib/docker/:/var/lib/docker:ro
|
||||||
116
script/test/fixtures/configmap-file-configs/output-k8s-1.yaml
vendored
Normal file
116
script/test/fixtures/configmap-file-configs/output-k8s-1.yaml
vendored
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "8081"
|
||||||
|
port: 8081
|
||||||
|
targetPort: 8080
|
||||||
|
- name: "8026"
|
||||||
|
port: 8026
|
||||||
|
targetPort: 8025
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.network/configmap-file-configs-default: "true"
|
||||||
|
io.kompose.service: busy
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- args:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- cat /auth.txt /users.php /certs/cert1.pem
|
||||||
|
image: busybox
|
||||||
|
name: busy
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
hostPort: 8081
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8025
|
||||||
|
hostPort: 8026
|
||||||
|
protocol: TCP
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /certs
|
||||||
|
name: busy-cm0
|
||||||
|
- mountPath: /auth.txt
|
||||||
|
name: busy-cm1
|
||||||
|
subPath: auth.txt
|
||||||
|
- mountPath: /users.php
|
||||||
|
name: busy-cm2
|
||||||
|
subPath: users.php
|
||||||
|
readOnly: true
|
||||||
|
restartPolicy: Always
|
||||||
|
volumes:
|
||||||
|
- configMap:
|
||||||
|
name: busy-cm0
|
||||||
|
name: busy-cm0
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: auth.txt
|
||||||
|
path: auth.txt
|
||||||
|
name: busy-cm1
|
||||||
|
name: busy-cm1
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: users.php
|
||||||
|
path: users.php
|
||||||
|
name: busy-cm2
|
||||||
|
name: busy-cm2
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
cert1.pem: |
|
||||||
|
content of file cert1.pem
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm0
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
auth.txt: |
|
||||||
|
content from file auth.txt
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm1
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
users.php: |
|
||||||
|
content from file users.php
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm2
|
||||||
137
script/test/fixtures/configmap-file-configs/output-k8s-2.yaml
vendored
Normal file
137
script/test/fixtures/configmap-file-configs/output-k8s-2.yaml
vendored
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "8081"
|
||||||
|
port: 8081
|
||||||
|
targetPort: 8080
|
||||||
|
- name: "8026"
|
||||||
|
port: 8026
|
||||||
|
targetPort: 8025
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.network/configmap-file-configs-default: "true"
|
||||||
|
io.kompose.service: busy
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- args:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- cat /auth.txt /users.php /certs/cert1.pem /certs/cert2.pem
|
||||||
|
image: busybox
|
||||||
|
name: busy
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
hostPort: 8081
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8025
|
||||||
|
hostPort: 8026
|
||||||
|
protocol: TCP
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /certs
|
||||||
|
name: busy-cm0
|
||||||
|
- mountPath: /certs/cert2.pem
|
||||||
|
name: busy-cm1
|
||||||
|
subPath: cert2.pem
|
||||||
|
- mountPath: /auth.txt
|
||||||
|
name: busy-cm2
|
||||||
|
subPath: auth.txt
|
||||||
|
- mountPath: /users.php
|
||||||
|
name: busy-cm3
|
||||||
|
readOnly: true
|
||||||
|
subPath: users.php
|
||||||
|
restartPolicy: Always
|
||||||
|
volumes:
|
||||||
|
- configMap:
|
||||||
|
name: busy-cm0
|
||||||
|
name: busy-cm0
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: cert2.pem
|
||||||
|
path: cert2.pem
|
||||||
|
name: busy-cm1
|
||||||
|
name: busy-cm1
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: auth.txt
|
||||||
|
path: auth.txt
|
||||||
|
name: busy-cm2
|
||||||
|
name: busy-cm2
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: users.php
|
||||||
|
path: users.php
|
||||||
|
name: busy-cm3
|
||||||
|
name: busy-cm3
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
cert1.pem: |
|
||||||
|
content of file cert1.pem
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm0
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
cert2.pem: content from file cert2.pem
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm1
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
auth.txt: |
|
||||||
|
content from file auth.txt
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm2
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
users.php: |
|
||||||
|
content from file users.php
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm3
|
||||||
49
script/test/fixtures/configmap-file-configs/output-k8s-3.yaml
vendored
Normal file
49
script/test/fixtures/configmap-file-configs/output-k8s-3.yaml
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "8081"
|
||||||
|
port: 8081
|
||||||
|
targetPort: 8080
|
||||||
|
- name: "8026"
|
||||||
|
port: 8026
|
||||||
|
targetPort: 8025
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.network/configmap-file-configs-default: "true"
|
||||||
|
io.kompose.service: busy
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: busybox
|
||||||
|
name: busy
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
hostPort: 8081
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8025
|
||||||
|
hostPort: 8026
|
||||||
|
protocol: TCP
|
||||||
|
restartPolicy: Always
|
||||||
144
script/test/fixtures/configmap-file-configs/output-os-1.yaml
vendored
Normal file
144
script/test/fixtures/configmap-file-configs/output-os-1.yaml
vendored
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "8081"
|
||||||
|
port: 8081
|
||||||
|
targetPort: 8080
|
||||||
|
- name: "8026"
|
||||||
|
port: 8026
|
||||||
|
targetPort: 8025
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps.openshift.io/v1
|
||||||
|
kind: DeploymentConfig
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.network/configmap-file-configs-default: "true"
|
||||||
|
io.kompose.service: busy
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- args:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- cat /auth.txt /users.php /certs/cert1.pem
|
||||||
|
image: ' '
|
||||||
|
name: busy
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
hostPort: 8081
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8025
|
||||||
|
hostPort: 8026
|
||||||
|
protocol: TCP
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /certs
|
||||||
|
name: busy-cm0
|
||||||
|
- mountPath: /auth.txt
|
||||||
|
name: busy-cm1
|
||||||
|
subPath: auth.txt
|
||||||
|
- mountPath: /users.php
|
||||||
|
name: busy-cm2
|
||||||
|
readOnly: true
|
||||||
|
subPath: users.php
|
||||||
|
restartPolicy: Always
|
||||||
|
volumes:
|
||||||
|
- configMap:
|
||||||
|
name: busy-cm0
|
||||||
|
name: busy-cm0
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: auth.txt
|
||||||
|
path: auth.txt
|
||||||
|
name: busy-cm1
|
||||||
|
name: busy-cm1
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: users.php
|
||||||
|
path: users.php
|
||||||
|
name: busy-cm2
|
||||||
|
name: busy-cm2
|
||||||
|
test: false
|
||||||
|
triggers:
|
||||||
|
- type: ConfigChange
|
||||||
|
- imageChangeParams:
|
||||||
|
automatic: true
|
||||||
|
containerNames:
|
||||||
|
- busy
|
||||||
|
from:
|
||||||
|
kind: ImageStreamTag
|
||||||
|
name: busy:latest
|
||||||
|
type: ImageChange
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: image.openshift.io/v1
|
||||||
|
kind: ImageStream
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
lookupPolicy:
|
||||||
|
local: false
|
||||||
|
tags:
|
||||||
|
- from:
|
||||||
|
kind: DockerImage
|
||||||
|
name: busybox
|
||||||
|
name: latest
|
||||||
|
referencePolicy:
|
||||||
|
type: ""
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
cert1.pem: |
|
||||||
|
content of file cert1.pem
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm0
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
auth.txt: |
|
||||||
|
content from file auth.txt
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm1
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
users.php: |
|
||||||
|
content from file users.php
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm2
|
||||||
165
script/test/fixtures/configmap-file-configs/output-os-2.yaml
vendored
Normal file
165
script/test/fixtures/configmap-file-configs/output-os-2.yaml
vendored
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "8081"
|
||||||
|
port: 8081
|
||||||
|
targetPort: 8080
|
||||||
|
- name: "8026"
|
||||||
|
port: 8026
|
||||||
|
targetPort: 8025
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps.openshift.io/v1
|
||||||
|
kind: DeploymentConfig
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.network/configmap-file-configs-default: "true"
|
||||||
|
io.kompose.service: busy
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- args:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- cat /auth.txt /users.php /certs/cert1.pem /certs/cert2.pem
|
||||||
|
image: ' '
|
||||||
|
name: busy
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
hostPort: 8081
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8025
|
||||||
|
hostPort: 8026
|
||||||
|
protocol: TCP
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /certs
|
||||||
|
name: busy-cm0
|
||||||
|
- mountPath: /certs/cert2.pem
|
||||||
|
name: busy-cm1
|
||||||
|
subPath: cert2.pem
|
||||||
|
- mountPath: /auth.txt
|
||||||
|
name: busy-cm2
|
||||||
|
subPath: auth.txt
|
||||||
|
- mountPath: /users.php
|
||||||
|
name: busy-cm3
|
||||||
|
readOnly: true
|
||||||
|
subPath: users.php
|
||||||
|
restartPolicy: Always
|
||||||
|
volumes:
|
||||||
|
- configMap:
|
||||||
|
name: busy-cm0
|
||||||
|
name: busy-cm0
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: cert2.pem
|
||||||
|
path: cert2.pem
|
||||||
|
name: busy-cm1
|
||||||
|
name: busy-cm1
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: auth.txt
|
||||||
|
path: auth.txt
|
||||||
|
name: busy-cm2
|
||||||
|
name: busy-cm2
|
||||||
|
- configMap:
|
||||||
|
items:
|
||||||
|
- key: users.php
|
||||||
|
path: users.php
|
||||||
|
name: busy-cm3
|
||||||
|
name: busy-cm3
|
||||||
|
test: false
|
||||||
|
triggers:
|
||||||
|
- type: ConfigChange
|
||||||
|
- imageChangeParams:
|
||||||
|
automatic: true
|
||||||
|
containerNames:
|
||||||
|
- busy
|
||||||
|
from:
|
||||||
|
kind: ImageStreamTag
|
||||||
|
name: busy:latest
|
||||||
|
type: ImageChange
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: image.openshift.io/v1
|
||||||
|
kind: ImageStream
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
lookupPolicy:
|
||||||
|
local: false
|
||||||
|
tags:
|
||||||
|
- from:
|
||||||
|
kind: DockerImage
|
||||||
|
name: busybox
|
||||||
|
name: latest
|
||||||
|
referencePolicy:
|
||||||
|
type: ""
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
cert1.pem: |
|
||||||
|
content of file cert1.pem
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm0
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
cert2.pem: content from file cert2.pem
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm1
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
auth.txt: |
|
||||||
|
content from file auth.txt
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm2
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
users.php: |
|
||||||
|
content from file users.php
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
use-subpath: "true"
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy-cm3
|
||||||
77
script/test/fixtures/configmap-file-configs/output-os-3.yaml
vendored
Normal file
77
script/test/fixtures/configmap-file-configs/output-os-3.yaml
vendored
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "8081"
|
||||||
|
port: 8081
|
||||||
|
targetPort: 8080
|
||||||
|
- name: "8026"
|
||||||
|
port: 8026
|
||||||
|
targetPort: 8025
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps.openshift.io/v1
|
||||||
|
kind: DeploymentConfig
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
io.kompose.service: busy
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.network/configmap-file-configs-default: "true"
|
||||||
|
io.kompose.service: busy
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: ' '
|
||||||
|
name: busy
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
hostPort: 8081
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8025
|
||||||
|
hostPort: 8026
|
||||||
|
protocol: TCP
|
||||||
|
restartPolicy: Always
|
||||||
|
test: false
|
||||||
|
triggers:
|
||||||
|
- type: ConfigChange
|
||||||
|
- imageChangeParams:
|
||||||
|
automatic: true
|
||||||
|
containerNames:
|
||||||
|
- busy
|
||||||
|
from:
|
||||||
|
kind: ImageStreamTag
|
||||||
|
name: busy:latest
|
||||||
|
type: ImageChange
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: image.openshift.io/v1
|
||||||
|
kind: ImageStream
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
io.kompose.service: busy
|
||||||
|
name: busy
|
||||||
|
spec:
|
||||||
|
lookupPolicy:
|
||||||
|
local: false
|
||||||
|
tags:
|
||||||
|
- from:
|
||||||
|
kind: DockerImage
|
||||||
|
name: busybox
|
||||||
|
name: latest
|
||||||
|
referencePolicy:
|
||||||
|
type: ""
|
||||||
1
script/test/fixtures/configmap-file-configs/users.php
vendored
Normal file
1
script/test/fixtures/configmap-file-configs/users.php
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
content from file users.php
|
||||||
Loading…
Reference in New Issue
Block a user