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

Switch to internalclientset #11916

Merged
merged 2 commits into from Nov 25, 2016
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.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 13 additions & 13 deletions pkg/api/graph/test/petset.yaml
Expand Up @@ -8,9 +8,9 @@ items:
labels:
app: mysql
name: mysql
namespace: default
namespace: example
resourceVersion: "6790"
selfLink: /apis/apps/v1alpha1/namespaces/default/petsets/mysql
selfLink: /apis/apps/v1alpha1/namespaces/example/petsets/mysql
uid: 3900c985-4f5b-11e6-b8a1-080027242396
spec:
replicas: 3
Expand Down Expand Up @@ -99,9 +99,9 @@ items:
labels:
app: mysql
name: galera
namespace: default
namespace: example
resourceVersion: "343"
selfLink: /api/v1/namespaces/default/services/galera
selfLink: /api/v1/namespaces/example/services/galera
uid: 38fb3915-4f5b-11e6-b8a1-080027242396
spec:
clusterIP: None
Expand All @@ -121,7 +121,7 @@ items:
metadata:
annotations:
kubernetes.io/created-by: |
{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"PetSet","namespace":"default","name":"mysql","uid":"3900c985-4f5b-11e6-b8a1-080027242396","apiVersion":"apps","resourceVersion":"6784"}}
{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"PetSet","namespace":"example","name":"mysql","uid":"3900c985-4f5b-11e6-b8a1-080027242396","apiVersion":"apps","resourceVersion":"6784"}}
openshift.io/scc: anyuid
pod.alpha.kubernetes.io/init-container-statuses: '[{"name":"install","state":{"terminated":{"exitCode":0,"reason":"Completed","startedAt":"2016-07-27T02:41:12Z","finishedAt":"2016-07-27T02:41:12Z","containerID":"docker://5c727d8732899605fcfe3eecbeeb02576f18f5b989496073340427a8d2134622"}},"lastState":{},"ready":true,"restartCount":0,"image":"gcr.io/google_containers/galera-install:0.1","imageID":"docker://sha256:56ef857005d0ce479f2db0e4ee0ece05e0766ebfa7e79e27e1513915262a18ec","containerID":"docker://5c727d8732899605fcfe3eecbeeb02576f18f5b989496073340427a8d2134622"},{"name":"bootstrap","state":{"terminated":{"exitCode":0,"reason":"Completed","startedAt":"2016-07-27T02:41:14Z","finishedAt":"2016-07-27T02:41:15Z","containerID":"docker://ab4ca0b3b6ec4860cd55c615534e1e2b11f4c3a33746783aab145919feb2446e"}},"lastState":{},"ready":true,"restartCount":0,"image":"debian:jessie","imageID":"docker://sha256:1b088884749bd93867ddb48ff404d4bbff09a17af8d95bc863efa5d133f87b78","containerID":"docker://ab4ca0b3b6ec4860cd55c615534e1e2b11f4c3a33746783aab145919feb2446e"}]'
pod.alpha.kubernetes.io/init-containers: '[{"name":"install","image":"gcr.io/google_containers/galera-install:0.1","args":["--work-dir=/work-dir"],"resources":{},"volumeMounts":[{"name":"workdir","mountPath":"/work-dir"},{"name":"config","mountPath":"/etc/mysql"},{"name":"default-token-au2xq","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"Always"},{"name":"bootstrap","image":"debian:jessie","command":["/work-dir/peer-finder"],"args":["-on-start=\"/work-dir/on-start.sh\"","-service=galera"],"env":[{"name":"POD_NAMESPACE","valueFrom":{"fieldRef":{"apiVersion":"v1","fieldPath":"metadata.namespace"}}}],"resources":{},"volumeMounts":[{"name":"workdir","mountPath":"/work-dir"},{"name":"config","mountPath":"/etc/mysql"},{"name":"default-token-au2xq","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}]'
Expand All @@ -133,9 +133,9 @@ items:
labels:
app: mysql
name: mysql-0
namespace: default
namespace: example
resourceVersion: "7191"
selfLink: /api/v1/namespaces/default/pods/mysql-0
selfLink: /api/v1/namespaces/example/pods/mysql-0
uid: 92e49e79-53a3-11e6-b45a-080027242396
spec:
containers:
Expand Down Expand Up @@ -244,7 +244,7 @@ items:
metadata:
annotations:
kubernetes.io/created-by: |
{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"PetSet","namespace":"default","name":"mysql","uid":"3900c985-4f5b-11e6-b8a1-080027242396","apiVersion":"apps","resourceVersion":"6790"}}
{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"PetSet","namespace":"example","name":"mysql","uid":"3900c985-4f5b-11e6-b8a1-080027242396","apiVersion":"apps","resourceVersion":"6790"}}
openshift.io/scc: anyuid
pod.alpha.kubernetes.io/init-container-statuses: '[{"name":"install","state":{"terminated":{"exitCode":0,"reason":"Completed","startedAt":"2016-07-27T02:41:42Z","finishedAt":"2016-07-27T02:41:42Z","containerID":"docker://2538c65f65557955c02745ef4021181cf322c8dc0db62144dd1e1f8ea9f7fa54"}},"lastState":{},"ready":true,"restartCount":0,"image":"gcr.io/google_containers/galera-install:0.1","imageID":"docker://sha256:56ef857005d0ce479f2db0e4ee0ece05e0766ebfa7e79e27e1513915262a18ec","containerID":"docker://2538c65f65557955c02745ef4021181cf322c8dc0db62144dd1e1f8ea9f7fa54"},{"name":"bootstrap","state":{"terminated":{"exitCode":0,"reason":"Completed","startedAt":"2016-07-27T02:41:44Z","finishedAt":"2016-07-27T02:41:45Z","containerID":"docker://4df7188d37033c182e675d45179941766bd1e6a013469038f43fa3fecc2cc06d"}},"lastState":{},"ready":true,"restartCount":0,"image":"debian:jessie","imageID":"docker://sha256:1b088884749bd93867ddb48ff404d4bbff09a17af8d95bc863efa5d133f87b78","containerID":"docker://4df7188d37033c182e675d45179941766bd1e6a013469038f43fa3fecc2cc06d"}]'
pod.alpha.kubernetes.io/init-containers: '[{"name":"install","image":"gcr.io/google_containers/galera-install:0.1","args":["--work-dir=/work-dir"],"resources":{},"volumeMounts":[{"name":"workdir","mountPath":"/work-dir"},{"name":"config","mountPath":"/etc/mysql"},{"name":"default-token-au2xq","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"Always"},{"name":"bootstrap","image":"debian:jessie","command":["/work-dir/peer-finder"],"args":["-on-start=\"/work-dir/on-start.sh\"","-service=galera"],"env":[{"name":"POD_NAMESPACE","valueFrom":{"fieldRef":{"apiVersion":"v1","fieldPath":"metadata.namespace"}}}],"resources":{},"volumeMounts":[{"name":"workdir","mountPath":"/work-dir"},{"name":"config","mountPath":"/etc/mysql"},{"name":"default-token-au2xq","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}]'
Expand All @@ -256,9 +256,9 @@ items:
labels:
app: mysql
name: mysql-1
namespace: default
namespace: example
resourceVersion: "7195"
selfLink: /api/v1/namespaces/default/pods/mysql-1
selfLink: /api/v1/namespaces/example/pods/mysql-1
uid: a4da4725-53a3-11e6-b45a-080027242396
spec:
containers:
Expand Down Expand Up @@ -373,7 +373,7 @@ items:
metadata:
annotations:
kubernetes.io/created-by: |
{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"PetSet","namespace":"default","name":"mysql","uid":"3900c985-4f5b-11e6-b8a1-080027242396","apiVersion":"apps","resourceVersion":"6790"}}
{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"PetSet","namespace":"example","name":"mysql","uid":"3900c985-4f5b-11e6-b8a1-080027242396","apiVersion":"apps","resourceVersion":"6790"}}
openshift.io/scc: anyuid
pod.alpha.kubernetes.io/init-container-statuses: '[{"name":"install","state":{"terminated":{"exitCode":0,"reason":"Completed","startedAt":"2016-07-27T03:01:01Z","finishedAt":"2016-07-27T03:01:01Z","containerID":"docker://af008b4ce59d36695fbabf40ae2f7431b51441eb2e9c6962378937c06ac69a35"}},"lastState":{},"ready":true,"restartCount":0,"image":"gcr.io/google_containers/galera-install:0.1","imageID":"docker://sha256:56ef857005d0ce479f2db0e4ee0ece05e0766ebfa7e79e27e1513915262a18ec","containerID":"docker://af008b4ce59d36695fbabf40ae2f7431b51441eb2e9c6962378937c06ac69a35"},{"name":"bootstrap","state":{"terminated":{"exitCode":0,"reason":"Completed","startedAt":"2016-07-27T03:01:02Z","finishedAt":"2016-07-27T03:01:03Z","containerID":"docker://ee97005854130335b54a65429865956260b7729e51e6363ab05e63d5c7c9ee48"}},"lastState":{},"ready":true,"restartCount":0,"image":"debian:jessie","imageID":"docker://sha256:1b088884749bd93867ddb48ff404d4bbff09a17af8d95bc863efa5d133f87b78","containerID":"docker://ee97005854130335b54a65429865956260b7729e51e6363ab05e63d5c7c9ee48"}]'
pod.alpha.kubernetes.io/init-containers: '[{"name":"install","image":"gcr.io/google_containers/galera-install:0.1","args":["--work-dir=/work-dir"],"resources":{},"volumeMounts":[{"name":"workdir","mountPath":"/work-dir"},{"name":"config","mountPath":"/etc/mysql"},{"name":"default-token-au2xq","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"Always"},{"name":"bootstrap","image":"debian:jessie","command":["/work-dir/peer-finder"],"args":["-on-start=\"/work-dir/on-start.sh\"","-service=galera"],"env":[{"name":"POD_NAMESPACE","valueFrom":{"fieldRef":{"apiVersion":"v1","fieldPath":"metadata.namespace"}}}],"resources":{},"volumeMounts":[{"name":"workdir","mountPath":"/work-dir"},{"name":"config","mountPath":"/etc/mysql"},{"name":"default-token-au2xq","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}]'
Expand All @@ -385,9 +385,9 @@ items:
labels:
app: mysql
name: mysql-2
namespace: default
namespace: example
resourceVersion: "7226"
selfLink: /api/v1/namespaces/default/pods/mysql-2
selfLink: /api/v1/namespaces/example/pods/mysql-2
uid: 57e618f1-53a6-11e6-b215-080027242396
spec:
containers:
Expand Down
20 changes: 10 additions & 10 deletions pkg/bootstrap/docker/openshift/admin.go
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
kapi "k8s.io/kubernetes/pkg/api"
apierrors "k8s.io/kubernetes/pkg/api/errors"
kclient "k8s.io/kubernetes/pkg/client/unversioned"
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/serviceaccount"

"github.com/openshift/origin/pkg/bootstrap/docker/errors"
Expand All @@ -31,8 +31,8 @@ const (
)

// InstallRegistry checks whether a registry is installed and installs one if not already installed
func (h *Helper) InstallRegistry(kubeClient kclient.Interface, f *clientcmd.Factory, configDir, images string, out, errout io.Writer) error {
_, err := kubeClient.Services(DefaultNamespace).Get(SvcDockerRegistry)
func (h *Helper) InstallRegistry(kubeClient kclientset.Interface, f *clientcmd.Factory, configDir, images string, out, errout io.Writer) error {
_, err := kubeClient.Core().Services(DefaultNamespace).Get(SvcDockerRegistry)
if err == nil {
// If there's no error, the registry already exists
return nil
Expand Down Expand Up @@ -69,8 +69,8 @@ func (h *Helper) InstallRegistry(kubeClient kclient.Interface, f *clientcmd.Fact
}

// InstallRouter installs a default router on the OpenShift server
func (h *Helper) InstallRouter(kubeClient kclient.Interface, f *clientcmd.Factory, configDir, images, hostIP string, portForwarding bool, out, errout io.Writer) error {
_, err := kubeClient.Services(DefaultNamespace).Get(SvcRouter)
func (h *Helper) InstallRouter(kubeClient kclientset.Interface, f *clientcmd.Factory, configDir, images, hostIP string, portForwarding bool, out, errout io.Writer) error {
_, err := kubeClient.Core().Services(DefaultNamespace).Get(SvcRouter)
if err == nil {
// Router service already exists, nothing to do
return nil
Expand All @@ -84,18 +84,18 @@ func (h *Helper) InstallRouter(kubeClient kclient.Interface, f *clientcmd.Factor
// Create service account for router
routerSA := &kapi.ServiceAccount{}
routerSA.Name = "router"
_, err = kubeClient.ServiceAccounts("default").Create(routerSA)
_, err = kubeClient.Core().ServiceAccounts("default").Create(routerSA)
if err != nil {
return errors.NewError("cannot create router service account").WithCause(err).WithDetails(h.OriginLog())
}

// Add router SA to privileged SCC
privilegedSCC, err := kubeClient.SecurityContextConstraints().Get("privileged")
privilegedSCC, err := kubeClient.Core().SecurityContextConstraints().Get("privileged")
if err != nil {
return errors.NewError("cannot retrieve privileged SCC").WithCause(err).WithDetails(h.OriginLog())
}
privilegedSCC.Users = append(privilegedSCC.Users, serviceaccount.MakeUsername("default", "router"))
_, err = kubeClient.SecurityContextConstraints().Update(privilegedSCC)
_, err = kubeClient.Core().SecurityContextConstraints().Update(privilegedSCC)
if err != nil {
return errors.NewError("cannot update privileged SCC").WithCause(err).WithDetails(h.OriginLog())
}
Expand Down Expand Up @@ -186,10 +186,10 @@ func AddRoleToServiceAccount(osClient client.Interface, role, sa, namespace stri
return addRole.AddRole()
}

func AddSCCToServiceAccount(kubeClient kclient.Interface, scc, sa, namespace string) error {
func AddSCCToServiceAccount(kubeClient kclientset.Interface, scc, sa, namespace string) error {
modifySCC := policy.SCCModificationOptions{
SCCName: scc,
SCCInterface: kubeClient,
SCCInterface: kubeClient.Core(),
Subjects: []kapi.ObjectReference{
{
Namespace: namespace,
Expand Down
10 changes: 5 additions & 5 deletions pkg/bootstrap/docker/openshift/logging.go
Expand Up @@ -51,12 +51,12 @@ func instantiateTemplate(client client.Interface, mapper configcmd.Mapper, templ

// InstallLogging checks whether logging is installed and installs it if not already installed
func (h *Helper) InstallLogging(f *clientcmd.Factory, publicHostname, loggerHost, imagePrefix, imageVersion string) error {
osClient, kubeClient, err := f.Clients()
osClient, _, kubeClient, err := f.Clients()
if err != nil {
return errors.NewError("cannot obtain API clients").WithCause(err).WithDetails(h.OriginLog())
}

_, err = kubeClient.Namespaces().Get(loggingNamespace)
_, err = kubeClient.Core().Namespaces().Get(loggingNamespace)
if err == nil {
// If there's no error, the logging namespace already exists and we won't initialize it
return nil
Expand Down Expand Up @@ -91,15 +91,15 @@ func (h *Helper) InstallLogging(f *clientcmd.Factory, publicHostname, loggerHost
}

// Label all nodes with default fluentd label
nodeList, err := kubeClient.Nodes().List(kapi.ListOptions{})
nodeList, err := kubeClient.Core().Nodes().List(kapi.ListOptions{})
if err != nil {
return errors.NewError("cannot retrieve nodes").WithCause(err).WithDetails(h.OriginLog())
}

// Iterate through all nodes (there should only be one)
for _, node := range nodeList.Items {
node.Labels["logging-infra-fluentd"] = "true"
if _, err = kubeClient.Nodes().Update(&node); err != nil {
if _, err = kubeClient.Core().Nodes().Update(&node); err != nil {
return errors.NewError("cannot update labels on node %s", node.Name).WithCause(err)
}
}
Expand All @@ -113,7 +113,7 @@ func (h *Helper) InstallLogging(f *clientcmd.Factory, publicHostname, loggerHost
"es-cluster-size": "1",
"es-instance-ram": "1024M",
}
kubeClient.ConfigMaps(loggingNamespace).Create(loggingConfig)
kubeClient.Core().ConfigMaps(loggingNamespace).Create(loggingConfig)

// Instantiate logging deployer
deployerParams := map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/docker/openshift/metrics.go
Expand Up @@ -20,7 +20,7 @@ const (

// InstallMetrics checks whether metrics is installed and installs it if not already installed
func (h *Helper) InstallMetrics(f *clientcmd.Factory, hostName, imagePrefix, imageVersion string) error {
osClient, kubeClient, err := f.Clients()
osClient, kubeClient, _, err := f.Clients()
if err != nil {
return errors.NewError("cannot obtain API clients").WithCause(err).WithDetails(h.OriginLog())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/docker/openshift/project.go
Expand Up @@ -14,7 +14,7 @@ import (

// CreateProject creates a project
func CreateProject(f *clientcmd.Factory, name, display, desc, basecmd string, out io.Writer) error {
client, _, err := f.Clients()
client, _, _, err := f.Clients()
if err != nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/docker/status.go
Expand Up @@ -98,7 +98,7 @@ func (c *ClientStatusConfig) Status(f *clientcmd.Factory, out io.Writer) error {
}

func isHealthy(f *clientcmd.Factory) (bool, error) {
osClient, _, err := f.Clients()
osClient, _, _, err := f.Clients()
if err != nil {
return false, err
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/bootstrap/docker/up.go
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/spf13/cobra"

kerrors "k8s.io/kubernetes/pkg/api/errors"
kclient "k8s.io/kubernetes/pkg/client/unversioned"
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
kclientcmd "k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"

Expand Down Expand Up @@ -795,12 +795,16 @@ func (c *ClientStartConfig) Factory() (*clientcmd.Factory, error) {
}

// Clients returns clients for OpenShift and Kube
func (c *ClientStartConfig) Clients() (*client.Client, *kclient.Client, error) {
func (c *ClientStartConfig) Clients() (*client.Client, *kclientset.Clientset, error) {
f, err := c.Factory()
if err != nil {
return nil, nil, err
}
return f.Clients()
oc, _, kcset, err := f.Clients()
if err != nil {
return nil, nil, err
}
return oc, kcset, nil
}

// OpenShiftHelper returns a helper object to work with OpenShift on the server
Expand Down Expand Up @@ -943,7 +947,7 @@ func (c *ClientStartConfig) ShouldInitializeData() bool {
return true
}

if _, err = kclient.Services(openshift.DefaultNamespace).Get(openshift.SvcDockerRegistry); err != nil {
if _, err = kclient.Core().Services(openshift.DefaultNamespace).Get(openshift.SvcDockerRegistry); err != nil {
return true
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/build/cmd/reaper.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/golang/glog"
kapi "k8s.io/kubernetes/pkg/api"
kerrors "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/unversioned"
kclient "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/kubectl"
ktypes "k8s.io/kubernetes/pkg/types"
kutilerrors "k8s.io/kubernetes/pkg/util/errors"
Expand Down Expand Up @@ -84,7 +84,7 @@ func (reaper *BuildConfigReaper) Stop(namespace, name string, timeout time.Durat
if len(bcBuilds) > 0 {

// Add paused annotation to the build config pending the deletion
err = unversioned.RetryOnConflict(unversioned.DefaultRetry, func() error {
err = kclient.RetryOnConflict(kclient.DefaultRetry, func() error {

bc, err := reaper.oc.BuildConfigs(namespace).Get(name)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/build/controller/controller.go
Expand Up @@ -9,8 +9,8 @@ import (
errors "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/unversioned"
"k8s.io/kubernetes/pkg/client/record"
kclient "k8s.io/kubernetes/pkg/client/unversioned"

builddefaults "github.com/openshift/origin/pkg/build/admission/defaults"
buildoverrides "github.com/openshift/origin/pkg/build/admission/overrides"
Expand Down Expand Up @@ -269,7 +269,7 @@ func (bc *BuildController) resolveOutputDockerImageReference(build *buildapi.Bui
type BuildPodController struct {
BuildStore cache.Store
BuildUpdater buildclient.BuildUpdater
SecretClient kclient.SecretsNamespacer
SecretClient kcoreclient.SecretsGetter
PodManager podManager
}

Expand Down