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

Moves from discoveryv1beta1 to discoveryv1 API for EndpointSlices #66

Merged
merged 1 commit into from
Sep 22, 2022
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
12 changes: 6 additions & 6 deletions pkg/buildkit/worker/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/go-logr/logr"
autoscalingv1 "k8s.io/api/autoscaling/v1"
corev1 "k8s.io/api/core/v1"
discoveryv1beta1 "k8s.io/api/discovery/v1beta1"
discoveryv1 "k8s.io/api/discovery/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand All @@ -25,7 +25,7 @@ import (
"k8s.io/client-go/kubernetes"
appsv1typed "k8s.io/client-go/kubernetes/typed/apps/v1"
corev1typed "k8s.io/client-go/kubernetes/typed/core/v1"
discoveryv1beta1typed "k8s.io/client-go/kubernetes/typed/discovery/v1beta1"
discoveryv1typed "k8s.io/client-go/kubernetes/typed/discovery/v1"
"k8s.io/utils/pointer"

"github.com/dominodatalab/hephaestus/pkg/config"
Expand Down Expand Up @@ -74,7 +74,7 @@ type AutoscalingPool struct {
podClient corev1typed.PodInterface
nodeClient corev1typed.NodeInterface
eventClient corev1typed.EventInterface
endpointSliceClient discoveryv1beta1typed.EndpointSliceInterface
endpointSliceClient discoveryv1typed.EndpointSliceInterface

podListOptions metav1.ListOptions
endpointSliceListOptions metav1.ListOptions
Expand Down Expand Up @@ -121,7 +121,7 @@ func NewPool(
podClient: clientset.CoreV1().Pods(conf.Namespace),
nodeClient: clientset.CoreV1().Nodes(),
eventClient: clientset.CoreV1().Events(conf.Namespace),
endpointSliceClient: clientset.DiscoveryV1beta1().EndpointSlices(conf.Namespace),
endpointSliceClient: clientset.DiscoveryV1().EndpointSlices(conf.Namespace),
podListOptions: podListOptions,
endpointSliceListOptions: endpointSliceListOptions,
serviceName: conf.ServiceName,
Expand Down Expand Up @@ -292,7 +292,7 @@ func (p *AutoscalingPool) buildEndpointURL(ctx context.Context, pod corev1.Pod)

start := time.Now()
for event := range watcher.ResultChan() {
endpointSlice := event.Object.(*discoveryv1beta1.EndpointSlice)
endpointSlice := event.Object.(*discoveryv1.EndpointSlice)

if hostname = p.extractHostname(endpointSlice, pod.Name); hostname != "" {
break
Expand All @@ -319,7 +319,7 @@ func (p *AutoscalingPool) buildEndpointURL(ctx context.Context, pod corev1.Pod)
}

// generates internal hostname for pod using an endpoint slice
func (p *AutoscalingPool) extractHostname(epSlice *discoveryv1beta1.EndpointSlice, podName string) (hostname string) {
func (p *AutoscalingPool) extractHostname(epSlice *discoveryv1.EndpointSlice, podName string) (hostname string) {
var portPresent bool
for _, port := range epSlice.Ports {
if pointer.Int32Deref(port.Port, 0) == p.servicePort {
Expand Down
12 changes: 6 additions & 6 deletions pkg/buildkit/worker/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
appsv1 "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
corev1 "k8s.io/api/core/v1"
discoveryv1beta1 "k8s.io/api/discovery/v1beta1"
discoveryv1 "k8s.io/api/discovery/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -46,7 +46,7 @@ var (
Namespace: namespace,
},
Spec: appsv1.StatefulSetSpec{
Replicas: pointer.Int32Ptr(0),
Replicas: pointer.Int32(0),
Selector: &metav1.LabelSelector{
MatchLabels: testLabels,
},
Expand Down Expand Up @@ -89,14 +89,14 @@ var (
},
}

validEndpointSlice = &discoveryv1beta1.EndpointSlice{
validEndpointSlice = &discoveryv1.EndpointSlice{
ObjectMeta: metav1.ObjectMeta{
Name: "buildkit-bgk87",
Namespace: namespace,
},
Endpoints: []discoveryv1beta1.Endpoint{
Endpoints: []discoveryv1.Endpoint{
{
Conditions: discoveryv1beta1.EndpointConditions{
Conditions: discoveryv1.EndpointConditions{
Ready: pointer.Bool(true),
Serving: pointer.Bool(true),
},
Expand All @@ -107,7 +107,7 @@ var (
},
},
},
Ports: []discoveryv1beta1.EndpointPort{
Ports: []discoveryv1.EndpointPort{
{
Name: pointer.String("daemon"),
Port: pointer.Int32(1234),
Expand Down
2 changes: 1 addition & 1 deletion scripts/development/01-setup-minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

set -e

# TODO: we should be able to select and test against different versions of k8s
minikube start \
--kubernetes-version=v1.19.16 \
--extra-config=apiserver.service-node-port-range=1-65535 \
--cpus=4 \
--memory=16g \
Expand Down