Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove istio sidecar annotation from all examples #1338

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/v1beta1/bayesianoptimization-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: bayesianoptimization-example
spec:
objective:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/cmaes-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: cmaes-example
spec:
objective:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/custom-metricscollector-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: custom-metricscollector-example
spec:
objective:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/file-metricscollector-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: file-metricscollector-example
spec:
objective:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/fpga/xgboost-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: kubeflow.org/v1beta1
kind: Experiment
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: xgb-svhn-fpga
namespace: kubeflow
spec:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/grid-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: grid-example
spec:
objective:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/metric-strategy-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: metric-strategy-example
spec:
objective:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/random-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: random-example
spec:
objective:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/resume-experiment/from-volume-resume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: from-volume-resume
spec:
objective:
Expand Down
2 changes: 0 additions & 2 deletions examples/v1beta1/tpe-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: "kubeflow.org/v1beta1"
kind: Experiment
metadata:
namespace: kubeflow
labels:
controller-tools.k8s.io: "1.0"
name: tpe-example
spec:
objective:
Expand Down
3 changes: 0 additions & 3 deletions examples/v1beta1/trial-metadata-substitution.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ spec:
"custom-key": "custom-label"
spec:
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
spec:
containers:
- name: training-container
Expand Down
11 changes: 1 addition & 10 deletions pkg/controller.v1beta1/trial/trial_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"time"

"github.com/spf13/viper"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -45,8 +46,6 @@ import (
"github.com/kubeflow/katib/pkg/controller.v1beta1/consts"
"github.com/kubeflow/katib/pkg/controller.v1beta1/trial/managerclient"
trialutil "github.com/kubeflow/katib/pkg/controller.v1beta1/trial/util"
"github.com/kubeflow/katib/pkg/controller.v1beta1/util"
"github.com/spf13/viper"
)

const (
Expand Down Expand Up @@ -266,14 +265,6 @@ func (r *ReconcileTrial) reconcileJob(instance *trialsv1beta1.Trial, desiredJob
kind := desiredJob.GetKind()
gvk := schema.FromAPIVersionAndKind(apiVersion, kind)

// Add annotation to desired Job to disable istio sidecar
// TODO (andreyvelich): Can be removed after custom CRD implementation
err = util.TrainingJobAnnotations(desiredJob)
if err != nil {
logger.Error(err, "TrainingJobAnnotations error")
return nil, err
}

deployedJob := &unstructured.Unstructured{}
deployedJob.SetGroupVersionKind(gvk)
err = r.Get(context.TODO(), types.NamespacedName{Name: desiredJob.GetName(), Namespace: desiredJob.GetNamespace()}, deployedJob)
Expand Down
69 changes: 0 additions & 69 deletions pkg/controller.v1beta1/util/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@ limitations under the License.
package util

import (
batchv1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"

suggestionsv1beta1 "github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1beta1"
"github.com/kubeflow/katib/pkg/controller.v1beta1/consts"
pytorchv1 "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1"
tfv1 "github.com/kubeflow/tf-operator/pkg/apis/tensorflow/v1"
)

var (
Expand All @@ -39,70 +34,6 @@ func SuggestionAnnotations(instance *suggestionsv1beta1.Suggestion) map[string]s
consts.AnnotationIstioSidecarInjectValue)
}

// TrainingJobAnnotations adds annotations to unstructured job.
func TrainingJobAnnotations(desiredJob *unstructured.Unstructured) error {
kind := desiredJob.GetKind()
switch kind {
case consts.JobKindJob:
batchJob := &batchv1.Job{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(desiredJob.Object, &batchJob)
if err != nil {
log.Error(err, "Convert unstructured to job error")
return err
}
batchJob.Spec.Template.ObjectMeta.Annotations = appendAnnotation(
batchJob.Spec.Template.ObjectMeta.Annotations,
consts.AnnotationIstioSidecarInjectName,
consts.AnnotationIstioSidecarInjectValue)
desiredJob.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(batchJob)
if err != nil {
log.Error(err, "Convert job to unstructured error")
return err
}
return nil
case consts.JobKindTF:
tfJob := &tfv1.TFJob{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(desiredJob.Object, &tfJob)
if err != nil {
log.Error(err, "Convert unstructured to TFJob error")
return err
}
for _, replicaSpec := range tfJob.Spec.TFReplicaSpecs {
replicaSpec.Template.ObjectMeta.Annotations = appendAnnotation(
replicaSpec.Template.ObjectMeta.Annotations,
consts.AnnotationIstioSidecarInjectName,
consts.AnnotationIstioSidecarInjectValue)
}
desiredJob.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(tfJob)
if err != nil {
log.Error(err, "Convert TFJob to unstructured error")
return err
}
return nil
case consts.JobKindPyTorch:
pytorchJob := &pytorchv1.PyTorchJob{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(desiredJob.Object, &pytorchJob)
if err != nil {
log.Error(err, "Convert unstructured to PytorchJob error")
return err
}
for _, replicaSpec := range pytorchJob.Spec.PyTorchReplicaSpecs {
replicaSpec.Template.ObjectMeta.Annotations = appendAnnotation(
replicaSpec.Template.ObjectMeta.Annotations,
consts.AnnotationIstioSidecarInjectName,
consts.AnnotationIstioSidecarInjectValue)
}
desiredJob.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(pytorchJob)
if err != nil {
log.Error(err, "Convert PytorchJob to unstructured error")
return err
}
return nil
default:
return nil
}
}

func appendAnnotation(annotations map[string]string, newAnnotationName string, newAnnotationValue string) map[string]string {
res := make(map[string]string)
for k, v := range annotations {
Expand Down