Skip to content

Commit

Permalink
Merge pull request #54 from cybozu-go/k8s-1.27
Browse files Browse the repository at this point in the history
add or change k8s v1.27
  • Loading branch information
takara9 committed Oct 30, 2023
2 parents 1fc225c + 282affa commit 6e5347f
Show file tree
Hide file tree
Showing 21 changed files with 251 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
name: End-to-End Tests
strategy:
matrix:
k8s-version: ["1.24.12", "1.25.8", "1.26.3"]
k8s-version: ["1.25.8", "1.26.3", "1.27.3"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM quay.io/cybozu/golang:1.20-jammy as builder
FROM quay.io/cybozu/golang:1.21-jammy as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.runner
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ RUN --mount=type=cache,target=/go/pkg/mod \
FROM quay.io/cybozu/ubuntu:22.04
LABEL org.opencontainers.image.source https://github.com/cybozu-go/nyamber

ENV GO_VERSION=1.20.4
ENV PLACEMAT_VERSION=2.4.2
ENV GO_VERSION=1.21.3
ENV PLACEMAT_VERSION=2.4.3

ENV HOME=/home/nyamber
ENV GOPATH=${HOME}/go
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ STATICCHECK = $(LOCALBIN)/staticcheck
CRD_TO_MARKDOWN ?= $(LOCALBIN)/crd-to-markdown

## Tool Versions
CONTROLLER_TOOLS_VERSION ?= v0.12.0
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26.1
KUSTOMIZE_VERSION ?= v5.0.3
CONTROLLER_TOOLS_VERSION ?= v0.13.0

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
# the kubebuilder version of the ready-to-use can get by "./bin/setup-envtest list" command.
ENVTEST_K8S_VERSION = 1.27.1

# KUSTOMIZE_VERSION can be found at https://github.com/kubernetes-sigs/kustomize/releases
KUSTOMIZE_VERSION ?= v5.2.1

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
Expand Down Expand Up @@ -73,6 +77,10 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

# Generate manifests and code, and check if diff exists. When there are diffrences stop CI.
# To avoid CI stopping, edit anotation "controller-gen.kubebuilder.io/version:" in
# existing "nyamber.cybozu.io_virtualdcs.yaml" and "nyamber.cybozu.io_virtualdcs.yaml".
# both version must equal CONTROLLER_TOOLS_VERSION in Makefile.
.PHONY: check-generate
check-generate: ## Generate manifests and code, and check if diff exists.
$(MAKE) manifests
Expand All @@ -91,7 +99,6 @@ apidoc: $(wildcard api/*/*_types.go)
$(CRD_TO_MARKDOWN) -f api/v1beta1/autovirtualdc_types.go -n AutoVirtualDC > docs/crd_autovirtualdc.md

##@ Build

.PHONY: build
build: ## Build manager binary.
go build -o bin/manager main.go
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Nyamber is a custom controller to create Neco environment
- Create dctest pods on the specified schedule

## Supported Software
- Kubernetes: 1.24, 1.25, 1.26
- Kubernetes: 1.25, 1.26, 1.27

## Documentation

Expand Down
1 change: 0 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

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

14 changes: 7 additions & 7 deletions aqua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ registries:
name: local
path: registry.yaml
packages:
- name: kubernetes/kubectl@v1.26.4
- name: kubernetes-sigs/kubebuilder@v3.10.0
- name: kubernetes-sigs/kustomize@kustomize/v5.0.3
- name: kubernetes-sigs/kind@v0.18.0
- name: tilt-dev/tilt@v0.32.3
- name: tilt-dev/ctlptl@v0.8.18
- name: mikefarah/yq@v4.33.3
- name: kubernetes/kubectl@v1.27.7
- name: kubernetes-sigs/kubebuilder@v3.12.0
- name: kubernetes-sigs/kustomize@kustomize/v5.2.1
- name: kubernetes-sigs/kind@v0.20.0
- name: tilt-dev/tilt@v0.33.6
- name: tilt-dev/ctlptl@v0.8.22
- name: mikefarah/yq@v4.35.2
- name: clamoriniere/crd-to-markdown@v0.0.3
registry: local
2 changes: 1 addition & 1 deletion cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ apiVersion: ctlptl.dev/v1alpha1
kind: Cluster
name: kind-nyamber-dev
product: kind
kubernetesVersion: v1.26.3
kubernetesVersion: v1.27.3
registry: nyamber-registry
9 changes: 7 additions & 2 deletions cmd/nyamber-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -73,10 +75,13 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

webHookServer := webhook.NewServer(webhook.Options{
Port: 9443,
})
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
WebhookServer: webHookServer,
Metrics: metricsserver.Options{BindAddress: metricsAddr},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "f8a5f6ae.nyamber.cybozu.io",
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/nyamber.cybozu.io_autovirtualdcs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.13.0
name: autovirtualdcs.nyamber.cybozu.io
spec:
group: nyamber.cybozu.io
Expand Down Expand Up @@ -125,7 +125,7 @@ spec:
compute resources required. If Requests is omitted for
a container, it defaults to Limits if that is explicitly
specified, otherwise to an implementation-defined value.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
skipNecoApps:
Expand Down
5 changes: 3 additions & 2 deletions config/crd/bases/nyamber.cybozu.io_virtualdcs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.13.0
name: virtualdcs.nyamber.cybozu.io
spec:
group: nyamber.cybozu.io
Expand Down Expand Up @@ -104,7 +104,8 @@ spec:
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
skipNecoApps:
Expand Down
13 changes: 7 additions & 6 deletions controllers/autovirtualdc_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/clock/testing"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

type MockClock struct {
Expand All @@ -35,9 +36,9 @@ var _ = Describe("AutoVirtualDC controller", func() {
time.Sleep(100 * time.Millisecond)

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
LeaderElection: false,
MetricsBindAddress: "0",
Scheme: scheme,
LeaderElection: false,
Metrics: metricsserver.Options{BindAddress: "0"},
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -112,8 +113,8 @@ var _ = Describe("AutoVirtualDC controller", func() {
APIVersion: "nyamber.cybozu.io/v1beta1",
UID: avdc.UID,
Name: avdc.Name,
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
}
Expect(vdc.ObjectMeta.OwnerReferences).To(ContainElement(expectedOwnerReference))
})
Expand Down
7 changes: 3 additions & 4 deletions controllers/virtualdc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -446,7 +445,7 @@ func (r *VirtualDCReconciler) deleteService(ctx context.Context, vdc *nyamberv1b

// SetupWithManager sets up the controller with the Manager.
func (r *VirtualDCReconciler) SetupWithManager(mgr ctrl.Manager) error {
vdcHandler := func(o client.Object) []reconcile.Request {
vdcHandler := func(c context.Context, o client.Object) []reconcile.Request {
owner := o.GetLabels()[constants.LabelKeyOwnerNamespace]
if owner == "" {
return nil
Expand All @@ -456,8 +455,8 @@ func (r *VirtualDCReconciler) SetupWithManager(mgr ctrl.Manager) error {

return ctrl.NewControllerManagedBy(mgr).
For(&nyamberv1beta1.VirtualDC{}).
Watches(&source.Kind{Type: &corev1.Pod{}}, handler.EnqueueRequestsFromMapFunc(vdcHandler)).
Watches(&source.Kind{Type: &corev1.Service{}}, handler.EnqueueRequestsFromMapFunc(vdcHandler)).
Watches(&corev1.Pod{}, handler.EnqueueRequestsFromMapFunc(vdcHandler)).
Watches(&corev1.Service{}, handler.EnqueueRequestsFromMapFunc(vdcHandler)).
Complete(r)
}

Expand Down
9 changes: 5 additions & 4 deletions controllers/virtualdc_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

type mockJobProcessManager struct {
Expand Down Expand Up @@ -69,9 +70,9 @@ var _ = Describe("VirtualDC controller", func() {
time.Sleep(100 * time.Millisecond)

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
LeaderElection: false,
MetricsBindAddress: "0",
Scheme: scheme,
LeaderElection: false,
Metrics: metricsserver.Options{BindAddress: "0"},
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -497,6 +498,7 @@ kind: Pod`
})

It("should recreate the service resource when the service resource is deleted", func() {

By("creating a VirtualDC resource")
vdc := &nyamberv1beta1.VirtualDC{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -514,7 +516,6 @@ kind: Pod`
}).Should(Succeed())

uid := svc.GetUID()

err = k8sClient.Delete(ctx, svc)
Expect(err).NotTo(HaveOccurred())
Eventually(func() error {
Expand Down
4 changes: 2 additions & 2 deletions e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NOTE: kind version is specified at aqua.yaml
E2ETEST_K8S_VERSION := 1.26.3
CERT_MANAGER_VERSION := 1.11.2
E2ETEST_K8S_VERSION := 1.27.3
CERT_MANAGER_VERSION := 1.13.1

PROJECT_DIR := $(CURDIR)/../
BIN_DIR := $(PROJECT_DIR)/bin
Expand Down
Loading

0 comments on commit 6e5347f

Please sign in to comment.