Skip to content

Commit

Permalink
Merge pull request #163 from JohnNiang/bug/admission-review-v1-not-found
Browse files Browse the repository at this point in the history
Upgrade controller-manager from 0.4.0 to 0.7.1
  • Loading branch information
zryfish authored Nov 2, 2021
2 parents 014d648 + c2e7e3f commit 56f9327
Show file tree
Hide file tree
Showing 2,908 changed files with 2,963 additions and 1,157,590 deletions.
62 changes: 50 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ IMG ?= kubespheredev/s2ioperator:latest
NAMESPACE ?= kubesphere-devops-system
export GO111MODULE=on

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

all: test manager

# Run tests
Expand All @@ -23,14 +36,14 @@ install-crd: manifests
kubectl apply -f config/crds

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests update-cert
deploy: manifests update-cert kustomize
kubectl apply -f config/templates
kubectl apply -f config/crds
kubectl kustomize config | kubectl apply -f -
$(KUSTOMIZE) config | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
manifests:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd:trivialVersions=true rbac:roleName=manager-role paths="./pkg/apis/...;./pkg/controller/..." output:crd:artifacts:config=config/crds
manifests: controller-gen
$(CONTROLLER_GEN) crd:trivialVersions=true rbac:roleName=manager-role paths="./pkg/apis/...;./pkg/controller/..." output:crd:artifacts:config=config/crds

# Run go fmt against code
fmt:
Expand All @@ -44,13 +57,12 @@ client-gen:
./hack/generate_group.sh all github.com/kubesphere/s2ioperator/pkg/client github.com/kubesphere/s2ioperator/pkg/apis "devops:v1alpha1" --go-header-file ./hack/boilerplate.go.txt

# Generate code
generate:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/...
go run vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go -O openapi_generated -i k8s.io/api/core/v1,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/util/intstr,k8s.io/apimachinery/pkg/version,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1 -p github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1 -h hack/boilerplate.go.txt --report-filename api/api-rules/violation_exceptions.list

generate: controller-gen openapi-gen
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/apis/...
$(OPENAPI_GEN) -O openapi_generated -i k8s.io/api/core/v1,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/util/intstr,k8s.io/apimachinery/pkg/version,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1 -p github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1 -h hack/boilerplate.go.txt --report-filename api/api-rules/violation_exceptions.list

# Build the docker image
docker-build:
docker-build: manager
docker build -f deploy/Dockerfile -t $(IMG) bin/
docker push $(IMG)

Expand All @@ -60,8 +72,8 @@ image-multiarch:
debug: manager
./hack/build-image.sh

release: manager test docker-build update-cert
kubectl kustomize config > deploy/s2ioperator.yaml
release: kustomize manager test docker-build update-cert
$(KUSTOMIZE) config > deploy/s2ioperator.yaml

install-travis:
chmod +x ./hack/*.sh
Expand All @@ -78,4 +90,30 @@ ca-secret:
update-cert: ca-secret
./hack/update-cert.sh

.PHONY : clean test
.PHONY : clean test

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])

KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])

OPENAPI_GEN = $(shell pwd)/bin/openapi-gen
openapi-gen: ## Download openapi-gen locally if necessary
$(call go-get-tool,$(OPENAPI_GEN),k8s.io/code-generator/cmd/[email protected])

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
25 changes: 2 additions & 23 deletions api/api-rules/violation_exceptions.list
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,Parameter,OptValues
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iAutoScale,Containers
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iBuildResult,ImageRepoTags
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iBuilderList,Items
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iBuilderTemplateList,Items
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iBuilderTemplateSpec,ContainerInfo
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iBuilderTemplateSpec,Parameters
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iConfig,AddHost
Expand All @@ -16,16 +14,13 @@ API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iConfig,NodeAffinityValues
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iConfig,RuntimeArtifacts
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iConfig,SecurityOpt
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iRunList,Items
API rule violation: list_type_missing,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,UserDefineTemplate,Parameters
API rule violation: list_type_missing,k8s.io/api/core/v1,AvoidPods,PreferAvoidPods
API rule violation: list_type_missing,k8s.io/api/core/v1,Capabilities,Add
API rule violation: list_type_missing,k8s.io/api/core/v1,Capabilities,Drop
API rule violation: list_type_missing,k8s.io/api/core/v1,CephFSPersistentVolumeSource,Monitors
API rule violation: list_type_missing,k8s.io/api/core/v1,CephFSVolumeSource,Monitors
API rule violation: list_type_missing,k8s.io/api/core/v1,ComponentStatus,Conditions
API rule violation: list_type_missing,k8s.io/api/core/v1,ComponentStatusList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ConfigMapList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ConfigMapProjection,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ConfigMapVolumeSource,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,Container,Args
Expand All @@ -41,7 +36,6 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,EndpointSubset,Addresse
API rule violation: list_type_missing,k8s.io/api/core/v1,EndpointSubset,NotReadyAddresses
API rule violation: list_type_missing,k8s.io/api/core/v1,EndpointSubset,Ports
API rule violation: list_type_missing,k8s.io/api/core/v1,Endpoints,Subsets
API rule violation: list_type_missing,k8s.io/api/core/v1,EndpointsList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,Args
API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,Command
API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,Env
Expand All @@ -50,23 +44,18 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommo
API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,VolumeDevices
API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,VolumeMounts
API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainers,EphemeralContainers
API rule violation: list_type_missing,k8s.io/api/core/v1,EventList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ExecAction,Command
API rule violation: list_type_missing,k8s.io/api/core/v1,FCVolumeSource,TargetWWNs
API rule violation: list_type_missing,k8s.io/api/core/v1,FCVolumeSource,WWIDs
API rule violation: list_type_missing,k8s.io/api/core/v1,HTTPGetAction,HTTPHeaders
API rule violation: list_type_missing,k8s.io/api/core/v1,HostAlias,Hostnames
API rule violation: list_type_missing,k8s.io/api/core/v1,ISCSIPersistentVolumeSource,Portals
API rule violation: list_type_missing,k8s.io/api/core/v1,ISCSIVolumeSource,Portals
API rule violation: list_type_missing,k8s.io/api/core/v1,LimitRangeList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,LimitRangeSpec,Limits
API rule violation: list_type_missing,k8s.io/api/core/v1,List,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,LoadBalancerStatus,Ingress
API rule violation: list_type_missing,k8s.io/api/core/v1,NamespaceList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,NamespaceSpec,Finalizers
API rule violation: list_type_missing,k8s.io/api/core/v1,NamespaceStatus,Conditions
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeAffinity,PreferredDuringSchedulingIgnoredDuringExecution
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSelector,NodeSelectorTerms
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSelectorRequirement,Values
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSelectorTerm,MatchExpressions
Expand All @@ -78,11 +67,9 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,Conditions
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,Images
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,VolumesAttached
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,VolumesInUse
API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeClaimList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeClaimSpec,AccessModes
API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeClaimStatus,AccessModes
API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeClaimStatus,Conditions
API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeSpec,AccessModes
API rule violation: list_type_missing,k8s.io/api/core/v1,PersistentVolumeSpec,MountOptions
API rule violation: list_type_missing,k8s.io/api/core/v1,PodAffinity,PreferredDuringSchedulingIgnoredDuringExecution
Expand All @@ -94,7 +81,6 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,PodDNSConfig,Nameserver
API rule violation: list_type_missing,k8s.io/api/core/v1,PodDNSConfig,Options
API rule violation: list_type_missing,k8s.io/api/core/v1,PodDNSConfig,Searches
API rule violation: list_type_missing,k8s.io/api/core/v1,PodExecOptions,Command
API rule violation: list_type_missing,k8s.io/api/core/v1,PodList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,PodPortForwardOptions,Ports
API rule violation: list_type_missing,k8s.io/api/core/v1,PodSecurityContext,SupplementalGroups
API rule violation: list_type_missing,k8s.io/api/core/v1,PodSecurityContext,Sysctls
Expand All @@ -111,26 +97,21 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,ContainerStat
API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,EphemeralContainerStatuses
API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,InitContainerStatuses
API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,PodIPs
API rule violation: list_type_missing,k8s.io/api/core/v1,PodTemplateList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ProjectedVolumeSource,Sources
API rule violation: list_type_missing,k8s.io/api/core/v1,RBDPersistentVolumeSource,CephMonitors
API rule violation: list_type_missing,k8s.io/api/core/v1,RBDVolumeSource,CephMonitors
API rule violation: list_type_missing,k8s.io/api/core/v1,RangeAllocation,Data
API rule violation: list_type_missing,k8s.io/api/core/v1,ReplicationControllerList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ReplicationControllerStatus,Conditions
API rule violation: list_type_missing,k8s.io/api/core/v1,ResourceQuotaList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ResourceQuotaSpec,Scopes
API rule violation: list_type_missing,k8s.io/api/core/v1,ScopeSelector,MatchExpressions
API rule violation: list_type_missing,k8s.io/api/core/v1,ScopedResourceSelectorRequirement,Values
API rule violation: list_type_missing,k8s.io/api/core/v1,SecretList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,SecretProjection,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,SecretVolumeSource,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceAccount,ImagePullSecrets
API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceAccount,Secrets
API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceAccountList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceList,Items
API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceSpec,ExternalIPs
API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceSpec,LoadBalancerSourceRanges
API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceSpec,TopologyKeys
API rule violation: list_type_missing,k8s.io/api/core/v1,TopologySelectorLabelRequirement,Values
API rule violation: list_type_missing,k8s.io/api/core/v1,TopologySelectorTerm,MatchLabelExpressions
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIGroup,ServerAddressByClientCIDRs
Expand All @@ -146,11 +127,9 @@ API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,Delet
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,FieldsV1,Raw
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,LabelSelector,MatchExpressions
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,LabelSelectorRequirement,Values
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,List,Items
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,Finalizers
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ManagedFields
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,OwnerReferences
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,PartialObjectMetadataList,Items
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,PatchOptions,DryRun
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,RootPaths,Paths
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,StatusDetails,Causes
Expand Down Expand Up @@ -182,7 +161,7 @@ API rule violation: names_match,k8s.io/api/core/v1,ISCSIPersistentVolumeSource,S
API rule violation: names_match,k8s.io/api/core/v1,ISCSIVolumeSource,DiscoveryCHAPAuth
API rule violation: names_match,k8s.io/api/core/v1,ISCSIVolumeSource,SessionCHAPAuth
API rule violation: names_match,k8s.io/api/core/v1,NodeResources,Capacity
API rule violation: names_match,k8s.io/api/core/v1,NodeSpec,DoNotUse_ExternalID
API rule violation: names_match,k8s.io/api/core/v1,NodeSpec,DoNotUseExternalID
API rule violation: names_match,k8s.io/api/core/v1,PersistentVolumeSource,CephFS
API rule violation: names_match,k8s.io/api/core/v1,PersistentVolumeSource,StorageOS
API rule violation: names_match,k8s.io/api/core/v1,PodSpec,DeprecatedServiceAccount
Expand Down
23 changes: 18 additions & 5 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,32 @@ package main

import (
"flag"
"os"

"github.com/kubesphere/s2ioperator/pkg/apis"
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
"github.com/kubesphere/s2ioperator/pkg/controller"
"github.com/kubesphere/s2ioperator/pkg/handler"
"github.com/kubesphere/s2ioperator/pkg/metrics"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"os"
"k8s.io/klog/klogr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
)

func init() {
// At startup, the default logger in controller runtime is a nil logger.
// We set it to klogr that is implemented by klog.
ctrl.SetLogger(klogr.New())
}

func main() {
var metricsAddr string
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.Parse()
logf.SetLogger(logf.ZapLogger(false))
log := logf.Log.WithName("entrypoint")
log := ctrl.Log.WithName("entrypoint")

// Get a config to talk to the apiserver
log.Info("setting up client for manager")
Expand All @@ -48,7 +55,13 @@ func main() {

// Create a newgo Cmd to provide shared dependencies and start components
log.Info("setting up manager")
mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: metricsAddr})
mgr, err := manager.New(cfg, manager.Options{
MetricsBindAddress: metricsAddr,
// We have to set the port to 443 for consistency, because the default port value has been changed
// from 443 to 9443 after controller-runtime 0.7.0
// Please see also https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.7.0
Port: 443,
})
if err != nil {
log.Error(err, "unable to set up overall controller manager")
os.Exit(1)
Expand Down
Loading

0 comments on commit 56f9327

Please sign in to comment.