Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
migrate logic and output update (#696)
Browse files Browse the repository at this point in the history
* update of migrate logic

* fix test

* remove profile related change

* update gen

* fix cni path

* add new test for overlay
  • Loading branch information
richardwxn authored and istio-testing committed Dec 19, 2019
1 parent 24504ea commit 80cdefb
Show file tree
Hide file tree
Showing 13 changed files with 1,042 additions and 728 deletions.
14 changes: 10 additions & 4 deletions cmd/mesh/manifest-migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,26 @@ func translateFunc(values []byte, l *Logger) error {
return fmt.Errorf("error creating values.yaml translator: %s", err)
}

isCPSpec, err := ts.TranslateFromValueToSpec(values)
translatedYAML, _, err := ts.TranslateFromValueToSpec(values)
if err != nil {
return fmt.Errorf("error translating values.yaml: %s", err)
}
isCP := &v1alpha2.IstioControlPlane{Spec: isCPSpec, Kind: "IstioControlPlane", ApiVersion: "install.istio.io/v1alpha2"}

translatedICPS := &v1alpha2.IstioControlPlaneSpec{}
err = util.UnmarshalWithJSONPB(translatedYAML, translatedICPS)
if err != nil {
return err
}

isCP := &v1alpha2.IstioControlPlane{Spec: translatedICPS, Kind: "IstioControlPlane", ApiVersion: "install.istio.io/v1alpha2"}

ms := jsonpb.Marshaler{}
gotString, err := ms.MarshalToString(isCP)
if err != nil {
return fmt.Errorf("error marshaling translated IstioControlPlane: %s", err)
}

isCPYaml, _ := yaml.JSONToYAML([]byte(gotString))
isCPYaml, err := yaml.JSONToYAML([]byte(gotString))
if err != nil {
return fmt.Errorf("error converting JSON: %s\n%s", gotString, err)
}
Expand Down Expand Up @@ -142,6 +149,5 @@ func migrateFromClusterConfig(rootArgs *rootArgs, mmArgs *manifestMigrateArgs, l
if err != nil {
return fmt.Errorf("error marshaling untyped map to YAML: %s", err)
}

return translateFunc(res, l)
}
5 changes: 4 additions & 1 deletion cmd/mesh/manifest-migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func TestManifestMigrate(t *testing.T) {
desc string
}{
{
desc: "values",
desc: "default_values",
},
{
desc: "overlay_values",
},
}
for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ certmanager:
tolerations: []
podAntiAffinityLabelSelector: []
podAntiAffinityTermLabelSelector: []
istio_cni:
cni:
enabled: false
hub: gcr.io/istio-release
tag: master-latest-daily
Expand Down
38 changes: 38 additions & 0 deletions cmd/mesh/testdata/manifest-migrate/input/overlay_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
gateways:
istio-ingressgateway:
autoscaleMin: 20
autoscaleMax: 20
tolerations:
- key: "scalers.istio"
operator: "Equal"
value: "dedicated"
effect: "NoSchedule"
nodeSelector:
scalers.istio: dedicated
podAntiAffinityTermLabelSelector:
- key: istio
operator: In
values: ingressgateway
topologyKey: "kubernetes.io/hostname"

pilot:
autoscaleMin: 20
autoscaleMax: 20
tolerations:
- key: "scalers.istio"
operator: "Equal"
value: "dedicated"
effect: "NoSchedule"
nodeSelector:
scalers.istio: dedicated
podAntiAffinityTermLabelSelector:
- key: istio
operator: In
values: pilot
topologyKey: "kubernetes.io/hostname"

mixer:
policy:
enabled: false
telemetry:
enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ spec:
replicaCount: 1
tag: v0.6.2
tolerations: []
cni:
cniBinDir: /opt/cni/bin
cniConfDir: /etc/cni/net.d
excludeNamespaces:
- istio-system
hub: gcr.io/istio-release
logLevel: info
pullPolicy: Always
tag: master-latest-daily
galley:
image: galley
podAntiAffinityLabelSelector: []
Expand Down Expand Up @@ -510,16 +519,6 @@ spec:
type: ClusterIP
storageClassName: ""
tolerations: []
istio_cni:
cniBinDir: /opt/cni/bin
cniConfDir: /etc/cni/net.d
enabled: false
excludeNamespaces:
- istio-system
hub: gcr.io/istio-release
logLevel: info
pullPolicy: Always
tag: master-latest-daily
istiocoredns:
coreDNSImage: coredns/coredns:1.1.2
coreDNSPluginImage: istio/coredns-plugin:0.2-istio-1.1
Expand Down
60 changes: 60 additions & 0 deletions cmd/mesh/testdata/manifest-migrate/output/overlay_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: install.istio.io/v1alpha2
kind: IstioControlPlane
metadata:
creationTimestamp: null
spec:
gateways:
components:
ingressGateway:
enabled: true
k8s:
nodeSelector:
scalers.istio: dedicated
tolerations:
- effect: NoSchedule
key: scalers.istio
operator: Equal
value: dedicated
enabled: true
policy:
components:
policy:
enabled: false
enabled: false
telemetry:
components:
telemetry:
enabled: false
enabled: false
trafficManagement:
components:
pilot:
enabled: true
k8s:
nodeSelector:
scalers.istio: dedicated
tolerations:
- effect: NoSchedule
key: scalers.istio
operator: Equal
value: dedicated
enabled: true
values:
gateways:
istio-ingressgateway:
autoscaleMax: 20
autoscaleMin: 20
podAntiAffinityTermLabelSelector:
- key: istio
operator: In
topologyKey: kubernetes.io/hostname
values: ingressgateway
pilot:
autoscaleMax: 20
autoscaleMin: 20
podAntiAffinityTermLabelSelector:
- key: istio
operator: In
topologyKey: kubernetes.io/hostname
values: pilot

90 changes: 90 additions & 0 deletions pkg/apis/istio/v1alpha1/v1alpha1.pb.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80cdefb

Please sign in to comment.