forked from LaconicNetwork/kompose
Network Key Translation Feature and test cases (#1195)
This commit is contained in:
parent
c13d50ee17
commit
ac2b852955
@ -59,7 +59,7 @@ __Glossary:__
|
|||||||
| links | x | x | x | | All containers in the same pod are accessible in Kubernetes |
|
| links | x | x | x | | All containers in the same pod are accessible in Kubernetes |
|
||||||
| logging | x | x | x | | Kubernetes has built-in logging support at the node-level |
|
| logging | x | x | x | | Kubernetes has built-in logging support at the node-level |
|
||||||
| network_mode | x | x | x | | Kubernetes uses its own cluster networking |
|
| network_mode | x | x | x | | Kubernetes uses its own cluster networking |
|
||||||
| networks | x | x | x | | See `networks` key |
|
| networks | ✓ | ✓ | ✓ | | See `networks` key |
|
||||||
| networks: aliases | x | x | x | | See `networks` key |
|
| networks: aliases | x | x | x | | See `networks` key |
|
||||||
| networks: addresses | x | x | x | | See `networks` key |
|
| networks: addresses | x | x | x | | See `networks` key |
|
||||||
| pid | ✓ | ✓ | ✓ | Pod.Spec.HostPID | |
|
| pid | ✓ | ✓ | ✓ | Pod.Spec.HostPID | |
|
||||||
|
|||||||
@ -72,20 +72,16 @@ func checkUnsupportedKey(composeProject *project.Project) []string {
|
|||||||
"Ulimits": false,
|
"Ulimits": false,
|
||||||
"Net": false,
|
"Net": false,
|
||||||
"Sysctls": false,
|
"Sysctls": false,
|
||||||
"Networks": false, // there are special checks for Network in checkUnsupportedKey function
|
//"Networks": false, // We shall be spporting network now. There are special checks for Network in checkUnsupportedKey function
|
||||||
"Links": false,
|
"Links": false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect all keys found in project
|
|
||||||
var keysFound []string
|
var keysFound []string
|
||||||
|
|
||||||
// Root level keys are not yet supported
|
// Root level keys are not yet supported except Network
|
||||||
// Check to see if the default network is available and length is only equal to one.
|
// Check to see if the default network is available and length is only equal to one.
|
||||||
// Else, warn the user that root level networks are not supported (yet)
|
|
||||||
if _, ok := composeProject.NetworkConfigs["default"]; ok && len(composeProject.NetworkConfigs) == 1 {
|
if _, ok := composeProject.NetworkConfigs["default"]; ok && len(composeProject.NetworkConfigs) == 1 {
|
||||||
log.Debug("Default network found")
|
log.Debug("Default network found")
|
||||||
} else if len(composeProject.NetworkConfigs) > 0 {
|
|
||||||
keysFound = append(keysFound, "root level networks")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Root level volumes are not yet supported
|
// Root level volumes are not yet supported
|
||||||
@ -117,8 +113,6 @@ func checkUnsupportedKey(composeProject *project.Project) []string {
|
|||||||
if len(serviceConfig.Networks.Networks) == 1 && serviceConfig.Networks.Networks[0].Name == "default" {
|
if len(serviceConfig.Networks.Networks) == 1 && serviceConfig.Networks.Networks[0].Name == "default" {
|
||||||
// this is empty Network definition, skip it
|
// this is empty Network definition, skip it
|
||||||
continue
|
continue
|
||||||
} else {
|
|
||||||
yamlTagName = "networks"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -260,7 +260,7 @@ func TestUnsupportedKeys(t *testing.T) {
|
|||||||
Ports: []string{}, // test empty array
|
Ports: []string{}, // test empty array
|
||||||
Networks: &yaml.Networks{
|
Networks: &yaml.Networks{
|
||||||
Networks: []*yaml.Network{
|
Networks: []*yaml.Network{
|
||||||
&yaml.Network{
|
{
|
||||||
Name: "net1",
|
Name: "net1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -275,19 +275,19 @@ func TestUnsupportedKeys(t *testing.T) {
|
|||||||
Ports: []string{}, // test empty array
|
Ports: []string{}, // test empty array
|
||||||
Networks: &yaml.Networks{
|
Networks: &yaml.Networks{
|
||||||
Networks: []*yaml.Network{
|
Networks: []*yaml.Network{
|
||||||
&yaml.Network{
|
{
|
||||||
Name: "net1",
|
Name: "net1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
projectWithNetworks.VolumeConfigs = map[string]*config.VolumeConfig{
|
projectWithNetworks.VolumeConfigs = map[string]*config.VolumeConfig{
|
||||||
"foo": &config.VolumeConfig{
|
"foo": {
|
||||||
Driver: "storage",
|
Driver: "storage",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
projectWithNetworks.NetworkConfigs = map[string]*config.NetworkConfig{
|
projectWithNetworks.NetworkConfigs = map[string]*config.NetworkConfig{
|
||||||
"foo": &config.NetworkConfig{
|
"foo": {
|
||||||
Driver: "bridge",
|
Driver: "bridge",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ func TestUnsupportedKeys(t *testing.T) {
|
|||||||
projectWithDefaultNetwork.ServiceConfigs.Add("foo", &config.ServiceConfig{
|
projectWithDefaultNetwork.ServiceConfigs.Add("foo", &config.ServiceConfig{
|
||||||
Networks: &yaml.Networks{
|
Networks: &yaml.Networks{
|
||||||
Networks: []*yaml.Network{
|
Networks: []*yaml.Network{
|
||||||
&yaml.Network{
|
{
|
||||||
Name: "default",
|
Name: "default",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -318,11 +318,8 @@ func TestUnsupportedKeys(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
"With Networks (service and root level)": {
|
"With Networks (service and root level)": {
|
||||||
projectWithNetworks,
|
projectWithNetworks,
|
||||||
[]string{"root level networks", "root level volumes", "networks"},
|
//root level network and network are now supported"
|
||||||
},
|
[]string{"root level volumes"},
|
||||||
"Empty Networks on Service level": {
|
|
||||||
projectWithEmptyNetwork,
|
|
||||||
[]string{"networks"},
|
|
||||||
},
|
},
|
||||||
"Default root level Network": {
|
"Default root level Network": {
|
||||||
projectWithDefaultNetwork,
|
projectWithDefaultNetwork,
|
||||||
@ -359,6 +356,29 @@ func TestNormalizeServiceNames(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNormalizeNetworkNames(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
composeNetworkName string
|
||||||
|
normalizedNetworkName string
|
||||||
|
}{
|
||||||
|
{"foo_bar", "foobar"},
|
||||||
|
{"foo", "foo"},
|
||||||
|
{"FOO", "foo"},
|
||||||
|
{"foo.bar", "foo.bar"},
|
||||||
|
//{"", ""},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
returnValue, err := normalizeNetworkNames(testCase.composeNetworkName)
|
||||||
|
if err != nil {
|
||||||
|
t.Log("Unxpected error, got ", err)
|
||||||
|
}
|
||||||
|
if returnValue != testCase.normalizedNetworkName {
|
||||||
|
t.Logf("Expected %q, got %q", testCase.normalizedNetworkName, returnValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCheckLabelsPorts(t *testing.T) {
|
func TestCheckLabelsPorts(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
@ -131,6 +131,17 @@ func normalizeVolumes(svcName string) string {
|
|||||||
return strings.Replace(svcName, "_", "-", -1)
|
return strings.Replace(svcName, "_", "-", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func normalizeNetworkNames(netName string) (string, error) {
|
||||||
|
netval := strings.ToLower(netName)
|
||||||
|
regString := ("[^A-Za-z0-9.-]+")
|
||||||
|
reg, err := regexp.Compile(regString)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
netval = reg.ReplaceAllString(netval, "")
|
||||||
|
return netval, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ReadFile read data from file or stdin
|
// ReadFile read data from file or stdin
|
||||||
func ReadFile(fileName string) ([]byte, error) {
|
func ReadFile(fileName string) ([]byte, error) {
|
||||||
if fileName == "-" {
|
if fileName == "-" {
|
||||||
|
|||||||
@ -24,8 +24,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
|
||||||
|
|
||||||
"github.com/docker/libcompose/config"
|
"github.com/docker/libcompose/config"
|
||||||
"github.com/docker/libcompose/lookup"
|
"github.com/docker/libcompose/lookup"
|
||||||
"github.com/docker/libcompose/project"
|
"github.com/docker/libcompose/project"
|
||||||
@ -33,6 +31,7 @@ import (
|
|||||||
"github.com/kubernetes/kompose/pkg/transformer"
|
"github.com/kubernetes/kompose/pkg/transformer"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"k8s.io/kubernetes/pkg/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse Docker Compose with libcompose (only supports v1 and v2). Eventually we will
|
// Parse Docker Compose with libcompose (only supports v1 and v2). Eventually we will
|
||||||
@ -279,6 +278,15 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
|
|||||||
serviceConfig.TmpFs = composeServiceConfig.Tmpfs
|
serviceConfig.TmpFs = composeServiceConfig.Tmpfs
|
||||||
serviceConfig.StopGracePeriod = composeServiceConfig.StopGracePeriod
|
serviceConfig.StopGracePeriod = composeServiceConfig.StopGracePeriod
|
||||||
|
|
||||||
|
if composeServiceConfig.Networks != nil {
|
||||||
|
if len(composeServiceConfig.Networks.Networks) > 0 {
|
||||||
|
for _, value := range composeServiceConfig.Networks.Networks {
|
||||||
|
if value.Name != "default" {
|
||||||
|
serviceConfig.Network = append(serviceConfig.Network, value.RealName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Get GroupAdd, group should be mentioned in gid format but not the group name
|
// Get GroupAdd, group should be mentioned in gid format but not the group name
|
||||||
groupAdd, err := getGroupAdd(composeServiceConfig.GroupAdd)
|
groupAdd, err := getGroupAdd(composeServiceConfig.GroupAdd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -281,6 +281,24 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
|
|||||||
serviceConfig.HostName = composeServiceConfig.Hostname
|
serviceConfig.HostName = composeServiceConfig.Hostname
|
||||||
serviceConfig.DomainName = composeServiceConfig.DomainName
|
serviceConfig.DomainName = composeServiceConfig.DomainName
|
||||||
|
|
||||||
|
//Adding network key related info
|
||||||
|
if len(composeServiceConfig.Networks) == 0 {
|
||||||
|
if defaultNetwork, ok := composeObject.Networks["default"]; ok {
|
||||||
|
serviceConfig.Network = append(serviceConfig.Network, defaultNetwork.Name)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var alias = ""
|
||||||
|
for key := range composeServiceConfig.Networks {
|
||||||
|
alias = key
|
||||||
|
netName := composeObject.Networks[alias].Name
|
||||||
|
// if Network Name Field is empty in the docker-compose definition
|
||||||
|
// we will use the alias name defined in service config file
|
||||||
|
if netName == "" {
|
||||||
|
netName = alias
|
||||||
|
}
|
||||||
|
serviceConfig.Network = append(serviceConfig.Network, netName)
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Deploy keys
|
// Deploy keys
|
||||||
//
|
//
|
||||||
|
|||||||
@ -501,7 +501,7 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic
|
|||||||
template.Spec.SecurityContext = podSecurityContext
|
template.Spec.SecurityContext = podSecurityContext
|
||||||
}
|
}
|
||||||
template.Spec.Containers[0].Ports = ports
|
template.Spec.Containers[0].Ports = ports
|
||||||
template.ObjectMeta.Labels = transformer.ConfigLabels(name)
|
template.ObjectMeta.Labels = transformer.ConfigLabelsWithNetwork(name, service.Network)
|
||||||
|
|
||||||
// Configure the image pull policy
|
// Configure the image pull policy
|
||||||
switch service.ImagePullPolicy {
|
switch service.ImagePullPolicy {
|
||||||
|
|||||||
@ -49,11 +49,12 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/kubernetes/kompose/pkg/loader/compose"
|
"github.com/kubernetes/kompose/pkg/loader/compose"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"k8s.io/kubernetes/pkg/api/meta"
|
"k8s.io/kubernetes/pkg/api/meta"
|
||||||
"k8s.io/kubernetes/pkg/labels"
|
"k8s.io/kubernetes/pkg/labels"
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Kubernetes implements Transformer interface and represents Kubernetes transformer
|
// Kubernetes implements Transformer interface and represents Kubernetes transformer
|
||||||
@ -303,14 +304,18 @@ func (k *Kubernetes) InitD(name string, service kobject.ServiceConfig, replicas
|
|||||||
},
|
},
|
||||||
Spec: extensions.DeploymentSpec{
|
Spec: extensions.DeploymentSpec{
|
||||||
Replicas: int32(replicas),
|
Replicas: int32(replicas),
|
||||||
|
|
||||||
Template: api.PodTemplateSpec{
|
Template: api.PodTemplateSpec{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
//Labels: transformer.ConfigLabels(name),
|
||||||
Annotations: transformer.ConfigAnnotations(service),
|
Annotations: transformer.ConfigAnnotations(service),
|
||||||
},
|
},
|
||||||
Spec: podSpec,
|
Spec: podSpec,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
dc.Spec.Template.Labels = transformer.ConfigLabels(name)
|
||||||
|
|
||||||
return dc
|
return dc
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,6 +828,36 @@ func (k *Kubernetes) InitPod(name string, service kobject.ServiceConfig) *api.Po
|
|||||||
return &pod
|
return &pod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateNetworkPolicy initializes Network policy
|
||||||
|
func (k *Kubernetes) CreateNetworkPolicy(name string, networkName string) (*extensions.NetworkPolicy, error) {
|
||||||
|
|
||||||
|
str := "true"
|
||||||
|
np := &extensions.NetworkPolicy{
|
||||||
|
TypeMeta: unversioned.TypeMeta{
|
||||||
|
Kind: "NetworkPolicy",
|
||||||
|
APIVersion: "extensions/v1beta1",
|
||||||
|
},
|
||||||
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
Name: networkName,
|
||||||
|
//Labels: transformer.ConfigLabels(name)(name),
|
||||||
|
},
|
||||||
|
Spec: extensions.NetworkPolicySpec{
|
||||||
|
PodSelector: unversioned.LabelSelector{
|
||||||
|
MatchLabels: map[string]string{"io.kompose.network/" + networkName: str},
|
||||||
|
},
|
||||||
|
Ingress: []extensions.NetworkPolicyIngressRule{{
|
||||||
|
From: []extensions.NetworkPolicyPeer{{
|
||||||
|
PodSelector: &unversioned.LabelSelector{
|
||||||
|
MatchLabels: map[string]string{"io.kompose.network/" + networkName: str},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return np, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Transform maps komposeObject to k8s objects
|
// Transform maps komposeObject to k8s objects
|
||||||
// returns object that are already sorted in the way that Services are first
|
// returns object that are already sorted in the way that Services are first
|
||||||
func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.ConvertOptions) ([]runtime.Object, error) {
|
func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.ConvertOptions) ([]runtime.Object, error) {
|
||||||
@ -906,11 +941,29 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.
|
|||||||
return nil, errors.Wrap(err, "Error transforming Kubernetes objects")
|
return nil, errors.Wrap(err, "Error transforming Kubernetes objects")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(service.Network) > 0 {
|
||||||
|
|
||||||
|
for _, net := range service.Network {
|
||||||
|
|
||||||
|
log.Infof("Network %s is detected at Source, shall be converted to equivalent NetworkPolicy at Destination", net)
|
||||||
|
np, err := k.CreateNetworkPolicy(name, net)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "Unable to create Network Policy for network %v for service %v", net, name)
|
||||||
|
}
|
||||||
|
objects = append(objects, np)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
allobjects = append(allobjects, objects...)
|
allobjects = append(allobjects, objects...)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort all object so Services are first
|
// sort all object so Services are first
|
||||||
k.SortServicesFirst(&allobjects)
|
k.SortServicesFirst(&allobjects)
|
||||||
|
|
||||||
return allobjects, nil
|
return allobjects, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ func newServiceConfig() kobject.ServiceConfig {
|
|||||||
WorkingDir: "dir",
|
WorkingDir: "dir",
|
||||||
Args: []string{"arg1", "arg2"},
|
Args: []string{"arg1", "arg2"},
|
||||||
VolList: []string{"/tmp/volume"},
|
VolList: []string{"/tmp/volume"},
|
||||||
Network: []string{"network1", "network2"}, // not supported
|
Network: []string{"network1", "network2"}, // supported
|
||||||
Labels: nil,
|
Labels: nil,
|
||||||
Annotations: map[string]string{"abc": "def"},
|
Annotations: map[string]string{"abc": "def"},
|
||||||
CPUQuota: 1, // not supported
|
CPUQuota: 1, // not supported
|
||||||
@ -278,15 +278,15 @@ func TestKomposeConvert(t *testing.T) {
|
|||||||
opt kobject.ConvertOptions
|
opt kobject.ConvertOptions
|
||||||
expectedNumObjs int
|
expectedNumObjs int
|
||||||
}{
|
}{
|
||||||
// objects generated are deployment, service and pvc
|
// objects generated are deployment, service nework policies (2) and pvc
|
||||||
"Convert to Deployments (D)": {newKomposeObject(), kobject.ConvertOptions{CreateD: true, Replicas: replicas, IsReplicaSetFlag: true}, 3},
|
"Convert to Deployments (D)": {newKomposeObject(), kobject.ConvertOptions{CreateD: true, Replicas: replicas, IsReplicaSetFlag: true}, 5},
|
||||||
"Convert to Deployments (D) with v3 replicas": {newKomposeObject(), kobject.ConvertOptions{CreateD: true}, 3},
|
"Convert to Deployments (D) with v3 replicas": {newKomposeObject(), kobject.ConvertOptions{CreateD: true}, 5},
|
||||||
"Convert to DaemonSets (DS)": {newKomposeObject(), kobject.ConvertOptions{CreateDS: true}, 3},
|
"Convert to DaemonSets (DS)": {newKomposeObject(), kobject.ConvertOptions{CreateDS: true}, 5},
|
||||||
"Convert to ReplicationController(RC)": {newKomposeObject(), kobject.ConvertOptions{CreateRC: true, Replicas: replicas, IsReplicaSetFlag: true}, 3},
|
"Convert to ReplicationController(RC)": {newKomposeObject(), kobject.ConvertOptions{CreateRC: true, Replicas: replicas, IsReplicaSetFlag: true}, 5},
|
||||||
"Convert to ReplicationController(RC) with v3 replicas ": {newKomposeObject(), kobject.ConvertOptions{CreateRC: true}, 3},
|
"Convert to ReplicationController(RC) with v3 replicas ": {newKomposeObject(), kobject.ConvertOptions{CreateRC: true}, 5},
|
||||||
// objects generated are deployment, daemonset, ReplicationController, service and pvc
|
// objects generated are deployment, daemonset, ReplicationController, service and pvc
|
||||||
"Convert to D, DS, and RC": {newKomposeObject(), kobject.ConvertOptions{CreateD: true, CreateDS: true, CreateRC: true, Replicas: replicas, IsReplicaSetFlag: true}, 5},
|
"Convert to D, DS, and RC": {newKomposeObject(), kobject.ConvertOptions{CreateD: true, CreateDS: true, CreateRC: true, Replicas: replicas, IsReplicaSetFlag: true}, 7},
|
||||||
"Convert to D, DS, and RC with v3 replicas": {newKomposeObject(), kobject.ConvertOptions{CreateD: true, CreateDS: true, CreateRC: true}, 5},
|
"Convert to D, DS, and RC with v3 replicas": {newKomposeObject(), kobject.ConvertOptions{CreateD: true, CreateDS: true, CreateRC: true}, 7},
|
||||||
// TODO: add more tests
|
// TODO: add more tests
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +306,7 @@ func TestKomposeConvert(t *testing.T) {
|
|||||||
name := "app"
|
name := "app"
|
||||||
labels := transformer.ConfigLabels(name)
|
labels := transformer.ConfigLabels(name)
|
||||||
config := test.komposeObject.ServiceConfigs[name]
|
config := test.komposeObject.ServiceConfigs[name]
|
||||||
|
labelsWithNetwork := transformer.ConfigLabelsWithNetwork(name, config.Network)
|
||||||
// Check results
|
// Check results
|
||||||
for _, obj := range objs {
|
for _, obj := range objs {
|
||||||
if svc, ok := obj.(*api.Service); ok {
|
if svc, ok := obj.(*api.Service); ok {
|
||||||
@ -319,7 +320,7 @@ func TestKomposeConvert(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if test.opt.CreateD {
|
if test.opt.CreateD {
|
||||||
if d, ok := obj.(*extensions.Deployment); ok {
|
if d, ok := obj.(*extensions.Deployment); ok {
|
||||||
if err := checkPodTemplate(config, d.Spec.Template, labels); err != nil {
|
if err := checkPodTemplate(config, d.Spec.Template, labelsWithNetwork); err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
if err := checkMeta(config, d.ObjectMeta, name, true); err != nil {
|
if err := checkMeta(config, d.ObjectMeta, name, true); err != nil {
|
||||||
@ -345,7 +346,7 @@ func TestKomposeConvert(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if test.opt.CreateDS {
|
if test.opt.CreateDS {
|
||||||
if ds, ok := obj.(*extensions.DaemonSet); ok {
|
if ds, ok := obj.(*extensions.DaemonSet); ok {
|
||||||
if err := checkPodTemplate(config, ds.Spec.Template, labels); err != nil {
|
if err := checkPodTemplate(config, ds.Spec.Template, labelsWithNetwork); err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
if err := checkMeta(config, ds.ObjectMeta, name, true); err != nil {
|
if err := checkMeta(config, ds.ObjectMeta, name, true); err != nil {
|
||||||
@ -359,7 +360,7 @@ func TestKomposeConvert(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if test.opt.CreateRC {
|
if test.opt.CreateRC {
|
||||||
if rc, ok := obj.(*api.ReplicationController); ok {
|
if rc, ok := obj.(*api.ReplicationController); ok {
|
||||||
if err := checkPodTemplate(config, *rc.Spec.Template, labels); err != nil {
|
if err := checkPodTemplate(config, *rc.Spec.Template, labelsWithNetwork); err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
if err := checkMeta(config, rc.ObjectMeta, name, true); err != nil {
|
if err := checkMeta(config, rc.ObjectMeta, name, true); err != nil {
|
||||||
@ -386,7 +387,7 @@ func TestKomposeConvert(t *testing.T) {
|
|||||||
// TODO: k8s & openshift transformer is now separated; either separate the test or combine the transformer
|
// TODO: k8s & openshift transformer is now separated; either separate the test or combine the transformer
|
||||||
if test.opt.CreateDeploymentConfig {
|
if test.opt.CreateDeploymentConfig {
|
||||||
if dc, ok := obj.(*deployapi.DeploymentConfig); ok {
|
if dc, ok := obj.(*deployapi.DeploymentConfig); ok {
|
||||||
if err := checkPodTemplate(config, *dc.Spec.Template, labels); err != nil {
|
if err := checkPodTemplate(config, *dc.Spec.Template, labelsWithNetwork); err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
if err := checkMeta(config, dc.ObjectMeta, name, true); err != nil {
|
if err := checkMeta(config, dc.ObjectMeta, name, true); err != nil {
|
||||||
|
|||||||
@ -107,13 +107,27 @@ func isPath(substring string) bool {
|
|||||||
return strings.Contains(substring, "/") || substring == "."
|
return strings.Contains(substring, "/") || substring == "."
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigLabels configures label
|
// ConfigLabels configures label name alone
|
||||||
func ConfigLabels(name string) map[string]string {
|
func ConfigLabels(name string) map[string]string {
|
||||||
return map[string]string{Selector: name}
|
return map[string]string{Selector: name}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConfigLabels configures label and add Network Information in labels
|
||||||
|
func ConfigLabelsWithNetwork(name string, net []string) map[string]string {
|
||||||
|
|
||||||
|
labels := map[string]string{}
|
||||||
|
labels[Selector] = name
|
||||||
|
|
||||||
|
for _, n := range net {
|
||||||
|
labels["io.kompose.network/"+n] = "true"
|
||||||
|
}
|
||||||
|
return labels
|
||||||
|
//return map[string]string{Selector: name, "Network": net}
|
||||||
|
}
|
||||||
|
|
||||||
// ConfigAnnotations configures annotations
|
// ConfigAnnotations configures annotations
|
||||||
func ConfigAnnotations(service kobject.ServiceConfig) map[string]string {
|
func ConfigAnnotations(service kobject.ServiceConfig) map[string]string {
|
||||||
|
|
||||||
annotations := map[string]string{}
|
annotations := map[string]string{}
|
||||||
for key, value := range service.Annotations {
|
for key, value := range service.Annotations {
|
||||||
annotations[key] = value
|
annotations[key] = value
|
||||||
|
|||||||
@ -836,7 +836,7 @@ convert::expect_success "$cmd" "/tmp/output-k8s.json"
|
|||||||
## Test compose v3.5+
|
## Test compose v3.5+
|
||||||
cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-3.5.yaml"
|
cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-3.5.yaml"
|
||||||
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-k8s-3.5.json > /tmp/output-k8s.json
|
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-k8s-3.5.json > /tmp/output-k8s.json
|
||||||
convert::expect_success "$cmd" "/tmp/output-k8s.json"
|
convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json"
|
||||||
|
|
||||||
## Test OpenShift for compose v3.3
|
## Test OpenShift for compose v3.3
|
||||||
cmd="kompose --provider openshift convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-config-long.yaml"
|
cmd="kompose --provider openshift convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-config-long.yaml"
|
||||||
@ -861,3 +861,13 @@ go test -v github.com/kubernetes/kompose/script/test/cmd
|
|||||||
|
|
||||||
rm /tmp/output-k8s.json /tmp/output-os.json
|
rm /tmp/output-k8s.json /tmp/output-os.json
|
||||||
exit $EXIT_STATUS
|
exit $EXIT_STATUS
|
||||||
|
|
||||||
|
# Network Translation compose v3
|
||||||
|
cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network/docker-compose-v3.yaml convert --stdout -j"
|
||||||
|
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/network/output-k8s.json > /tmp/output-k8s.json
|
||||||
|
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/network/docker-compose-v3.yaml convert --stdout -j"
|
||||||
|
# OpenShift test
|
||||||
|
cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/network/docker-compose-v3.yaml convert --stdout -j"
|
||||||
|
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/network/output-os.json > /tmp/output-os.json
|
||||||
|
convert::expect_success "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/network/docker-compose-v3.yaml convert --stdout -j"
|
||||||
|
|
||||||
|
|||||||
15
script/test/fixtures/network/docker-compose-v3.yaml
vendored
Normal file
15
script/test/fixtures/network/docker-compose-v3.yaml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
version: '3'
|
||||||
|
networks:
|
||||||
|
app:
|
||||||
|
external:
|
||||||
|
name: app-network
|
||||||
|
web:
|
||||||
|
external:
|
||||||
|
name: web-network
|
||||||
|
services:
|
||||||
|
appFoo:
|
||||||
|
image: foo:latest
|
||||||
|
command: sh -c "echo Hello Foo"
|
||||||
|
networks:
|
||||||
|
app: {}
|
||||||
|
web: {}
|
||||||
112
script/test/fixtures/network/output-k8s.json
vendored
Normal file
112
script/test/fixtures/network/output-k8s.json
vendored
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
{
|
||||||
|
"kind": "List",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {},
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"kind": "Deployment",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "appfoo",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "appfoo"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.cmd": "%CMD%"
|
||||||
|
"kompose.version": "%VERSION%"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"replicas": 1,
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.network/app-network": "true",
|
||||||
|
"io.kompose.network/web-network": "true",
|
||||||
|
"io.kompose.service": "appfoo"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.cmd": "%CMD%"
|
||||||
|
"kompose.version": "%VERSION%"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "appfoo",
|
||||||
|
"image": "foo:latest",
|
||||||
|
"args": [
|
||||||
|
"sh",
|
||||||
|
"-c",
|
||||||
|
"echo Hello Foo"
|
||||||
|
],
|
||||||
|
"resources": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"strategy": {}
|
||||||
|
},
|
||||||
|
"status": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "app-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/app-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/app-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "web-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/web-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/web-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
104
script/test/fixtures/network/output-os.json
vendored
Normal file
104
script/test/fixtures/network/output-os.json
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
{
|
||||||
|
"kind": "List",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {},
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"kind": "DeploymentConfig",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "appfoo",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "appfoo"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.cmd": "%CMD%"
|
||||||
|
"kompose.version": "%VERSION%"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"strategy": {
|
||||||
|
"resources": {}
|
||||||
|
},
|
||||||
|
"triggers": [
|
||||||
|
{
|
||||||
|
"type": "ConfigChange"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImageChange",
|
||||||
|
"imageChangeParams": {
|
||||||
|
"automatic": true,
|
||||||
|
"containerNames": [
|
||||||
|
"appfoo"
|
||||||
|
],
|
||||||
|
"from": {
|
||||||
|
"kind": "ImageStreamTag",
|
||||||
|
"name": "appfoo:latest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replicas": 1,
|
||||||
|
"test": false,
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "appfoo"
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.network/app-network": "true",
|
||||||
|
"io.kompose.network/web-network": "true",
|
||||||
|
"io.kompose.service": "appfoo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "appfoo",
|
||||||
|
"image": " ",
|
||||||
|
"args": [
|
||||||
|
"sh",
|
||||||
|
"-c",
|
||||||
|
"echo Hello Foo"
|
||||||
|
],
|
||||||
|
"resources": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ImageStream",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "appfoo",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "appfoo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "latest",
|
||||||
|
"annotations": null,
|
||||||
|
"from": {
|
||||||
|
"kind": "DockerImage",
|
||||||
|
"name": "foo:latest"
|
||||||
|
},
|
||||||
|
"generation": null,
|
||||||
|
"importPolicy": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"dockerImageRepository": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
29
script/test/fixtures/v3/output-k8s-3.5.json
vendored
29
script/test/fixtures/v3/output-k8s-3.5.json
vendored
@ -53,6 +53,7 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"creationTimestamp": null,
|
"creationTimestamp": null,
|
||||||
"labels": {
|
"labels": {
|
||||||
|
"io.kompose.network/helloworld-network": "true",
|
||||||
"io.kompose.service": "helloworld"
|
"io.kompose.service": "helloworld"
|
||||||
},
|
},
|
||||||
"annotations": {
|
"annotations": {
|
||||||
@ -79,6 +80,34 @@
|
|||||||
"strategy": {}
|
"strategy": {}
|
||||||
},
|
},
|
||||||
"status": {}
|
"status": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "helloworld-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/helloworld-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/helloworld-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,9 @@
|
|||||||
"name": "foo",
|
"name": "foo",
|
||||||
"creationTimestamp": null,
|
"creationTimestamp": null,
|
||||||
"labels": {
|
"labels": {
|
||||||
|
"io.kompose.network/other-network": "true",
|
||||||
|
"io.kompose.network/other-other-network": "true",
|
||||||
|
"io.kompose.network/some-network": "true",
|
||||||
"io.kompose.service": "foo"
|
"io.kompose.service": "foo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -344,6 +347,90 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"status": {}
|
"status": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "other-other-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/other-other-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/other-other-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "some-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/some-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/some-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "other-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/other-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/other-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,6 +153,9 @@
|
|||||||
"name": "foo",
|
"name": "foo",
|
||||||
"creationTimestamp": null,
|
"creationTimestamp": null,
|
||||||
"labels": {
|
"labels": {
|
||||||
|
"io.kompose.network/other-network": "true",
|
||||||
|
"io.kompose.network/other-other-network": "true",
|
||||||
|
"io.kompose.network/some-network": "true",
|
||||||
"io.kompose.service": "foo"
|
"io.kompose.service": "foo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -503,6 +506,90 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"status": {}
|
"status": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "other-other-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/other-other-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/other-other-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "some-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/some-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/some-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "NetworkPolicy",
|
||||||
|
"apiVersion": "extensions/v1beta1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "other-network",
|
||||||
|
"creationTimestamp": null
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/other-network": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ingress": [
|
||||||
|
{
|
||||||
|
"from": [
|
||||||
|
{
|
||||||
|
"podSelector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.network/other-network": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,6 +153,9 @@
|
|||||||
"name": "foo",
|
"name": "foo",
|
||||||
"creationTimestamp": null,
|
"creationTimestamp": null,
|
||||||
"labels": {
|
"labels": {
|
||||||
|
"io.kompose.network/other-network": "true",
|
||||||
|
"io.kompose.network/other-other-network": "true",
|
||||||
|
"io.kompose.network/some-network": "true",
|
||||||
"io.kompose.service": "foo"
|
"io.kompose.service": "foo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user