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

Downgrade kubernetes dependency to 1.10.1 #256

Merged
merged 5 commits into from
Nov 28, 2018
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
112 changes: 24 additions & 88 deletions Gopkg.lock

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

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ required = [

[[constraint]]
name = "k8s.io/api"
version = "kubernetes-1.11.2"
version = "kubernetes-1.10.1"

[[constraint]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.11.2"
version = "kubernetes-1.10.1"

[[constraint]]
name = "k8s.io/client-go"
version = "kubernetes-1.11.2"
version = "kubernetes-1.10.1"

[[constraint]]
name = "sigs.k8s.io/controller-runtime"
version = "0.1.3"
version = "0.1.1"

[[override]]
name="k8s.io/apiextensions-apiserver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data:
namespace: kubeflow
spec:
schedule: "*/1 * * * *"
successfulJobsHistoryLimit: 1
successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 1
jobTemplate:
spec:
Expand Down
61 changes: 61 additions & 0 deletions pkg/controller/studyjob/pod_control.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package studyjob

import (
"log"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
)

type PodControl struct {
kubeClient clientset.Interface
}

func NewPodControl() (*PodControl, error) {
config, err := restclient.InClusterConfig()
if err != nil {
return nil, err
}
kc, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
return &PodControl{
kubeClient: kc,
}, nil
}

func (c PodControl) DeletePodsForWorker(namespace string, wid string) error {
selector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
MatchLabels: map[string]string{"job-name":wid},
})
if err != nil {
return err
}
log.Printf("Deleting pods with selector %v", selector.String())
listOptions := metav1.ListOptions{
LabelSelector: selector.String(),
}
err = c.kubeClient.CoreV1().Pods(namespace).DeleteCollection(&metav1.DeleteOptions{}, listOptions)
if err != nil {
return err
}
log.Printf("Deleted pods with selector %v.", selector.String())
return nil
}
Loading