Skip to content

Commit

Permalink
Merge pull request #77617 from cmluciano/cml/extensiontonetworking
Browse files Browse the repository at this point in the history
ingress: migrate extensions.Ingress to networking.Ingress
  • Loading branch information
k8s-ci-robot authored May 11, 2019
2 parents 9ecc57e + d9e4933 commit 33f44a2
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 75 deletions.
12 changes: 6 additions & 6 deletions pkg/kubectl/describe/versioned/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2291,15 +2291,15 @@ type IngressDescriber struct {
}

func (i *IngressDescriber) Describe(namespace, name string, describerSettings describe.DescriberSettings) (string, error) {
c := i.ExtensionsV1beta1().Ingresses(namespace)
c := i.NetworkingV1beta1().Ingresses(namespace)
ing, err := c.Get(name, metav1.GetOptions{})
if err != nil {
return "", err
}
return i.describeIngress(ing, describerSettings)
}

func (i *IngressDescriber) describeBackend(ns string, backend *extensionsv1beta1.IngressBackend) string {
func (i *IngressDescriber) describeBackend(ns string, backend *networkingv1beta1.IngressBackend) string {
endpoints, _ := i.CoreV1().Endpoints(ns).Get(backend.ServiceName, metav1.GetOptions{})
service, _ := i.CoreV1().Services(ns).Get(backend.ServiceName, metav1.GetOptions{})
spName := ""
Expand All @@ -2319,7 +2319,7 @@ func (i *IngressDescriber) describeBackend(ns string, backend *extensionsv1beta1
return formatEndpoints(endpoints, sets.NewString(spName))
}

func (i *IngressDescriber) describeIngress(ing *extensionsv1beta1.Ingress, describerSettings describe.DescriberSettings) (string, error) {
func (i *IngressDescriber) describeIngress(ing *networkingv1beta1.Ingress, describerSettings describe.DescriberSettings) (string, error) {
return tabbedString(func(out io.Writer) error {
w := NewPrefixWriter(out)
w.Write(LEVEL_0, "Name:\t%v\n", ing.Name)
Expand All @@ -2330,7 +2330,7 @@ func (i *IngressDescriber) describeIngress(ing *extensionsv1beta1.Ingress, descr
if def == nil {
// Ingresses that don't specify a default backend inherit the
// default backend in the kube-system namespace.
def = &extensionsv1beta1.IngressBackend{
def = &networkingv1beta1.IngressBackend{
ServiceName: "default-http-backend",
ServicePort: intstr.IntOrString{Type: intstr.Int, IntVal: 80},
}
Expand Down Expand Up @@ -2372,7 +2372,7 @@ func (i *IngressDescriber) describeIngress(ing *extensionsv1beta1.Ingress, descr
})
}

func describeIngressTLS(w PrefixWriter, ingTLS []extensionsv1beta1.IngressTLS) {
func describeIngressTLS(w PrefixWriter, ingTLS []networkingv1beta1.IngressTLS) {
w.Write(LEVEL_0, "TLS:\n")
for _, t := range ingTLS {
if t.SecretName == "" {
Expand Down Expand Up @@ -4494,7 +4494,7 @@ func extractCSRStatus(csr *certificatesv1beta1.CertificateSigningRequest) (strin
}

// backendStringer behaves just like a string interface and converts the given backend to a string.
func backendStringer(backend *extensionsv1beta1.IngressBackend) string {
func backendStringer(backend *networkingv1beta1.IngressBackend) string {
if backend == nil {
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/ingress/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_library(
deps = [
"//staging/src/k8s.io/api/apps/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
"//staging/src/k8s.io/api/networking/v1beta1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
Expand Down
70 changes: 35 additions & 35 deletions test/e2e/framework/ingress/ingress_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (

apps "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
networkingv1beta1 "k8s.io/api/networking/v1beta1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -186,20 +186,20 @@ func CreateIngressComformanceTests(jig *TestJig, ns string, annotations map[stri
fmt.Sprintf("should update url map for host %v to expose a single url: %v", updateURLMapHost, updateURLMapPath),
func() {
var pathToFail string
jig.Update(func(ing *extensions.Ingress) {
newRules := []extensions.IngressRule{}
jig.Update(func(ing *networkingv1beta1.Ingress) {
newRules := []networkingv1beta1.IngressRule{}
for _, rule := range ing.Spec.Rules {
if rule.Host != updateURLMapHost {
newRules = append(newRules, rule)
continue
}
existingPath := rule.IngressRuleValue.HTTP.Paths[0]
pathToFail = existingPath.Path
newRules = append(newRules, extensions.IngressRule{
newRules = append(newRules, networkingv1beta1.IngressRule{
Host: updateURLMapHost,
IngressRuleValue: extensions.IngressRuleValue{
HTTP: &extensions.HTTPIngressRuleValue{
Paths: []extensions.HTTPIngressPath{
IngressRuleValue: networkingv1beta1.IngressRuleValue{
HTTP: &networkingv1beta1.HTTPIngressRuleValue{
Paths: []networkingv1beta1.HTTPIngressPath{
{
Path: updateURLMapPath,
Backend: existingPath.Backend,
Expand All @@ -223,14 +223,14 @@ func CreateIngressComformanceTests(jig *TestJig, ns string, annotations map[stri
tests = append(tests, ConformanceTests{
fmt.Sprintf("should update SSL certificate with modified hostname %v", updatedTLSHost),
func() {
jig.Update(func(ing *extensions.Ingress) {
newRules := []extensions.IngressRule{}
jig.Update(func(ing *networkingv1beta1.Ingress) {
newRules := []networkingv1beta1.IngressRule{}
for _, rule := range ing.Spec.Rules {
if rule.Host != tlsHost {
newRules = append(newRules, rule)
continue
}
newRules = append(newRules, extensions.IngressRule{
newRules = append(newRules, networkingv1beta1.IngressRule{
Host: updatedTLSHost,
IngressRuleValue: rule.IngressRuleValue,
})
Expand Down Expand Up @@ -368,7 +368,7 @@ type TestJig struct {

RootCAs map[string][]byte
Address string
Ingress *extensions.Ingress
Ingress *networkingv1beta1.Ingress
// class is the value of the annotation keyed under
// `kubernetes.io/ingress.class`. It's added to all ingresses created by
// this jig.
Expand Down Expand Up @@ -436,9 +436,9 @@ func (j *TestJig) CreateIngress(manifestPath, ns string, ingAnnotations map[stri
}

// runCreate runs the required command to create the given ingress.
func (j *TestJig) runCreate(ing *extensions.Ingress) (*extensions.Ingress, error) {
func (j *TestJig) runCreate(ing *networkingv1beta1.Ingress) (*networkingv1beta1.Ingress, error) {
if j.Class != MulticlusterIngressClassValue {
return j.Client.ExtensionsV1beta1().Ingresses(ing.Namespace).Create(ing)
return j.Client.NetworkingV1beta1().Ingresses(ing.Namespace).Create(ing)
}
// Use kubemci to create a multicluster ingress.
filePath := framework.TestContext.OutputDir + "/mci.yaml"
Expand All @@ -450,9 +450,9 @@ func (j *TestJig) runCreate(ing *extensions.Ingress) (*extensions.Ingress, error
}

// runUpdate runs the required command to update the given ingress.
func (j *TestJig) runUpdate(ing *extensions.Ingress) (*extensions.Ingress, error) {
func (j *TestJig) runUpdate(ing *networkingv1beta1.Ingress) (*networkingv1beta1.Ingress, error) {
if j.Class != MulticlusterIngressClassValue {
return j.Client.ExtensionsV1beta1().Ingresses(ing.Namespace).Update(ing)
return j.Client.NetworkingV1beta1().Ingresses(ing.Namespace).Update(ing)
}
// Use kubemci to update a multicluster ingress.
// kubemci does not have an update command. We use "create --force" to update an existing ingress.
Expand All @@ -465,11 +465,11 @@ func (j *TestJig) runUpdate(ing *extensions.Ingress) (*extensions.Ingress, error
}

// Update retrieves the ingress, performs the passed function, and then updates it.
func (j *TestJig) Update(update func(ing *extensions.Ingress)) {
func (j *TestJig) Update(update func(ing *networkingv1beta1.Ingress)) {
var err error
ns, name := j.Ingress.Namespace, j.Ingress.Name
for i := 0; i < 3; i++ {
j.Ingress, err = j.Client.ExtensionsV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{})
j.Ingress, err = j.Client.NetworkingV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{})
if err != nil {
framework.Failf("failed to get ingress %s/%s: %v", ns, name, err)
}
Expand All @@ -493,8 +493,8 @@ func (j *TestJig) AddHTTPS(secretName string, hosts ...string) {
_, cert, _, err := createTLSSecret(j.Client, j.Ingress.Namespace, secretName, hosts...)
framework.ExpectNoError(err)
j.Logger.Infof("Updating ingress %v to also use secret %v for TLS termination", j.Ingress.Name, secretName)
j.Update(func(ing *extensions.Ingress) {
ing.Spec.TLS = append(ing.Spec.TLS, extensions.IngressTLS{Hosts: hosts, SecretName: secretName})
j.Update(func(ing *networkingv1beta1.Ingress) {
ing.Spec.TLS = append(ing.Spec.TLS, networkingv1beta1.IngressTLS{Hosts: hosts, SecretName: secretName})
})
j.RootCAs[secretName] = cert
}
Expand All @@ -504,23 +504,23 @@ func (j *TestJig) SetHTTPS(secretName string, hosts ...string) {
_, cert, _, err := createTLSSecret(j.Client, j.Ingress.Namespace, secretName, hosts...)
framework.ExpectNoError(err)
j.Logger.Infof("Updating ingress %v to only use secret %v for TLS termination", j.Ingress.Name, secretName)
j.Update(func(ing *extensions.Ingress) {
ing.Spec.TLS = []extensions.IngressTLS{{Hosts: hosts, SecretName: secretName}}
j.Update(func(ing *networkingv1beta1.Ingress) {
ing.Spec.TLS = []networkingv1beta1.IngressTLS{{Hosts: hosts, SecretName: secretName}}
})
j.RootCAs = map[string][]byte{secretName: cert}
}

// RemoveHTTPS updates the ingress to not use this secret for TLS.
// Note: Does not delete the secret.
func (j *TestJig) RemoveHTTPS(secretName string) {
newTLS := []extensions.IngressTLS{}
newTLS := []networkingv1beta1.IngressTLS{}
for _, ingressTLS := range j.Ingress.Spec.TLS {
if secretName != ingressTLS.SecretName {
newTLS = append(newTLS, ingressTLS)
}
}
j.Logger.Infof("Updating ingress %v to not use secret %v for TLS termination", j.Ingress.Name, secretName)
j.Update(func(ing *extensions.Ingress) {
j.Update(func(ing *networkingv1beta1.Ingress) {
ing.Spec.TLS = newTLS
})
delete(j.RootCAs, secretName)
Expand Down Expand Up @@ -551,16 +551,16 @@ func (j *TestJig) TryDeleteIngress() {
j.tryDeleteGivenIngress(j.Ingress)
}

func (j *TestJig) tryDeleteGivenIngress(ing *extensions.Ingress) {
func (j *TestJig) tryDeleteGivenIngress(ing *networkingv1beta1.Ingress) {
if err := j.runDelete(ing); err != nil {
j.Logger.Infof("Error while deleting the ingress %v/%v with class %s: %v", ing.Namespace, ing.Name, j.Class, err)
}
}

// runDelete runs the required command to delete the given ingress.
func (j *TestJig) runDelete(ing *extensions.Ingress) error {
func (j *TestJig) runDelete(ing *networkingv1beta1.Ingress) error {
if j.Class != MulticlusterIngressClassValue {
return j.Client.ExtensionsV1beta1().Ingresses(ing.Namespace).Delete(ing.Name, nil)
return j.Client.NetworkingV1beta1().Ingresses(ing.Namespace).Delete(ing.Name, nil)
}
// Use kubemci to delete a multicluster ingress.
filePath := framework.TestContext.OutputDir + "/mci.yaml"
Expand Down Expand Up @@ -600,7 +600,7 @@ func getIngressAddress(client clientset.Interface, ns, name, class string) ([]st
if class == MulticlusterIngressClassValue {
return getIngressAddressFromKubemci(name)
}
ing, err := client.ExtensionsV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{})
ing, err := client.NetworkingV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -635,7 +635,7 @@ func (j *TestJig) WaitForIngressAddress(c clientset.Interface, ns, ingName strin
return address, err
}

func (j *TestJig) pollIngressWithCert(ing *extensions.Ingress, address string, knownHosts []string, cert []byte, waitForNodePort bool, timeout time.Duration) error {
func (j *TestJig) pollIngressWithCert(ing *networkingv1beta1.Ingress, address string, knownHosts []string, cert []byte, waitForNodePort bool, timeout time.Duration) error {
// Check that all rules respond to a simple GET.
knownHostsSet := sets.NewString(knownHosts...)
for _, rules := range ing.Spec.Rules {
Expand Down Expand Up @@ -695,7 +695,7 @@ func (j *TestJig) WaitForIngressToStable() {
// http or https). If waitForNodePort is true, the NodePort of the Service
// is verified before verifying the Ingress. NodePort is currently a
// requirement for cloudprovider Ingress.
func (j *TestJig) WaitForGivenIngressWithTimeout(ing *extensions.Ingress, waitForNodePort bool, timeout time.Duration) error {
func (j *TestJig) WaitForGivenIngressWithTimeout(ing *networkingv1beta1.Ingress, waitForNodePort bool, timeout time.Duration) error {
// Wait for the loadbalancer IP.
address, err := j.WaitForIngressAddress(j.Client, ing.Namespace, ing.Name, timeout)
if err != nil {
Expand Down Expand Up @@ -864,15 +864,15 @@ func (cont *NginxIngressController) Init() {
framework.Logf("ingress controller running in pod %v on ip %v", cont.pod.Name, cont.externalIP)
}

func generateBacksideHTTPSIngressSpec(ns string) *extensions.Ingress {
return &extensions.Ingress{
func generateBacksideHTTPSIngressSpec(ns string) *networkingv1beta1.Ingress {
return &networkingv1beta1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "echoheaders-https",
Namespace: ns,
},
Spec: extensions.IngressSpec{
Spec: networkingv1beta1.IngressSpec{
// Note kubemci requires a default backend.
Backend: &extensions.IngressBackend{
Backend: &networkingv1beta1.IngressBackend{
ServiceName: "echoheaders-https",
ServicePort: intstr.IntOrString{
Type: intstr.Int,
Expand Down Expand Up @@ -939,7 +939,7 @@ func generateBacksideHTTPSDeploymentSpec() *apps.Deployment {
}

// SetUpBacksideHTTPSIngress sets up deployment, service and ingress with backside HTTPS configured.
func (j *TestJig) SetUpBacksideHTTPSIngress(cs clientset.Interface, namespace string, staticIPName string) (*apps.Deployment, *v1.Service, *extensions.Ingress, error) {
func (j *TestJig) SetUpBacksideHTTPSIngress(cs clientset.Interface, namespace string, staticIPName string) (*apps.Deployment, *v1.Service, *networkingv1beta1.Ingress, error) {
deployCreated, err := cs.AppsV1().Deployments(namespace).Create(generateBacksideHTTPSDeploymentSpec())
if err != nil {
return nil, nil, nil, err
Expand All @@ -963,7 +963,7 @@ func (j *TestJig) SetUpBacksideHTTPSIngress(cs clientset.Interface, namespace st
}

// DeleteTestResource deletes given deployment, service and ingress.
func (j *TestJig) DeleteTestResource(cs clientset.Interface, deploy *apps.Deployment, svc *v1.Service, ing *extensions.Ingress) []error {
func (j *TestJig) DeleteTestResource(cs clientset.Interface, deploy *apps.Deployment, svc *v1.Service, ing *networkingv1beta1.Ingress) []error {
var errs []error
if ing != nil {
if err := j.runDelete(ing); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/manifest/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go_library(
deps = [
"//staging/src/k8s.io/api/apps/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
"//staging/src/k8s.io/api/networking/v1beta1:go_default_library",
"//staging/src/k8s.io/api/rbac/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
Expand Down Expand Up @@ -41,5 +41,5 @@ go_test(
name = "go_default_test",
srcs = ["manifest_test.go"],
embed = [":go_default_library"],
deps = ["//staging/src/k8s.io/api/extensions/v1beta1:go_default_library"],
deps = ["//staging/src/k8s.io/api/networking/v1beta1:go_default_library"],
)
10 changes: 5 additions & 5 deletions test/e2e/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

apps "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
networkingv1beta1 "k8s.io/api/networking/v1beta1"
rbac "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -87,8 +87,8 @@ func SvcFromManifest(fileName string) (*v1.Service, error) {
}

// IngressFromManifest reads a .json/yaml file and returns the ingress in it.
func IngressFromManifest(fileName string) (*extensions.Ingress, error) {
var ing extensions.Ingress
func IngressFromManifest(fileName string) (*networkingv1beta1.Ingress, error) {
var ing networkingv1beta1.Ingress
data, err := testfiles.Read(fileName)
if err != nil {
return nil, err
Expand All @@ -106,8 +106,8 @@ func IngressFromManifest(fileName string) (*extensions.Ingress, error) {

// IngressToManifest generates a yaml file in the given path with the given ingress.
// Assumes that a directory exists at the given path.
func IngressToManifest(ing *extensions.Ingress, path string) error {
serialized, err := marshalToYaml(ing, extensions.SchemeGroupVersion)
func IngressToManifest(ing *networkingv1beta1.Ingress, path string) error {
serialized, err := marshalToYaml(ing, networkingv1beta1.SchemeGroupVersion)
if err != nil {
return fmt.Errorf("failed to marshal ingress %v to YAML: %v", ing, err)
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"path/filepath"
"testing"

extensions "k8s.io/api/extensions/v1beta1"
networkingv1beta1 "k8s.io/api/networking/v1beta1"
)

func TestIngressToManifest(t *testing.T) {
ing := &extensions.Ingress{}
ing := &networkingv1beta1.Ingress{}
// Create a temp dir.
tmpDir, err := ioutil.TempDir("", "kubemci")
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/network/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {

By(fmt.Sprintf("waiting for Ingress %s to get instance group annotation", name))
pollErr := wait.Poll(2*time.Second, framework.LoadBalancerPollTimeout, func() (bool, error) {
ing, err := f.ClientSet.ExtensionsV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{})
ing, err := f.ClientSet.NetworkingV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{})
framework.ExpectNoError(err)
annotations := ing.Annotations
if annotations == nil || annotations[instanceGroupAnnotation] == "" {
Expand All @@ -194,7 +194,7 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
scKey := ingress.StatusPrefix + "/ssl-cert"
beKey := ingress.StatusPrefix + "/backends"
wait.Poll(2*time.Second, time.Minute, func() (bool, error) {
ing, err := f.ClientSet.ExtensionsV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{})
ing, err := f.ClientSet.NetworkingV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{})
framework.ExpectNoError(err)
annotations := ing.Annotations
if annotations != nil && (annotations[umKey] != "" || annotations[fwKey] != "" ||
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/network/scale/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_library(
deps = [
"//staging/src/k8s.io/api/apps/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
"//staging/src/k8s.io/api/networking/v1beta1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
Expand Down
Loading

0 comments on commit 33f44a2

Please sign in to comment.