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

*: add support for 1.6 types #38

Merged
merged 4 commits into from
Mar 27, 2017
Merged

*: add support for 1.6 types #38

merged 4 commits into from
Mar 27, 2017

Conversation

ericchiang
Copy link
Owner

@ericchiang ericchiang commented Mar 27, 2017

Closes #35

Breaking changes

Over the 1.6 release cycle Kubernetes switched the ever present v1.ObjectMeta to its own API group. A non-breaking change to adopt this would require rewrites of all 1.6 proto files, so this client will do the same breaking change as the official client and switch the import path. Users should update code to refer to the new package.

As an example, the README snippet changed from:

import (
    "context"

    "github.com/ericchiang/k8s"
    "github.com/ericchiang/k8s/api/v1"
)

func createConfigMap(client *k8s.Client, name string, values map[string]string) error {
    cm := &v1.ConfigMap{
        Metadata: &v1.ObjectMeta{Name: &name, Namespace: &client.Namespace},
        Data:     values,
    }
    _, err := client.CoreV1().CreateConfigMap(context.TODO(), cm)
    return err
}

to:

import (
    "context"

    "github.com/ericchiang/k8s"
    "github.com/ericchiang/k8s/api/v1"
    metav1 "github.com/ericchiang/k8s/apis/meta/v1"
)

func createConfigMap(client *k8s.Client, name string, values map[string]string) error {
    cm := &v1.ConfigMap{
        Metadata: &metav1.ObjectMeta{Name: &name, Namespace: &client.Namespace},
        Data:     values,
    }
    _, err := client.CoreV1().CreateConfigMap(context.TODO(), cm)
    return err
}

API group changes

  • Authentication graduated from "v1beta1" to "v1"
  • Authorization graduated from "v1beta1" to "v1"
  • Autoscaling "v2alpha1" was introduced.
  • Certificates graduated from "v1alpha1" to "v1beta1"
  • RBAC graduated from "v1alpha1" to "v1beta1"
  • Settings "v1alpha1" was introduced.
  • Storage graduated from "v1beta1" to "v1"

What about alpha API groups only in 1.5?

As Kubernetes deprecates alpha APIs, the official client removes support for them. That means if you use an API group that was alpha in 1.5 and updated to beta in 1.6 (for example, RBAC or certificates), you can't compile a program with the official client that works on both versions.

This client preserves all API groups from all versions of Kubernetes, but wont do the translation for you. To support multiple Kubernetes versions, users should detect the version of the API server, then use the group associated with that version.

v, err := client.Discovery().Version(ctx)
if err != nil {
    return err
}

switch {
case v.Minor == 5:
    // Use client.RBACV1Alpha1
case v.Minor >= 6:
    // Use client.RBACV1Beta1
default:
    // unsupported version
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant