Skip to content

Commit

Permalink
Merge pull request #126 from runzexia/kubebuilder2
Browse files Browse the repository at this point in the history
bump to kubebuilder2
  • Loading branch information
runzexia authored Dec 12, 2019
2 parents 5217505 + df560d2 commit 9bf2b56
Show file tree
Hide file tree
Showing 1,005 changed files with 161,668 additions and 64,534 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# Image URL to use all building/pushing image targets
IMG ?= kubespheredev/s2ioperator:advanced-2.1.0
export GO111MODULE=on

all: test manager

Expand All @@ -23,11 +24,11 @@ install: manifests
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
kubectl apply -f config/crds
kustomize build config/default | kubectl apply -f -
kubectl 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 all
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd:trivialVersions=true rbac:roleName=manager-role webhook paths="./pkg/apis/...;./pkg/controller/..." output:crd:artifacts:config=config/crds

# Run go fmt against code
fmt:
Expand All @@ -38,11 +39,11 @@ vet:
go vet ./pkg/... ./cmd/...

client-gen:
./vendor/k8s.io/code-generator/generate-groups.sh all github.com/kubesphere/s2ioperator/pkg/client github.com/kubesphere/s2ioperator/pkg/apis "devops:v1alpha1" --go-header-file ./hack/boilerplate.go.txt
./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/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i github.com/kubesphere/s2ioperator/pkg/apis/... -h hack/boilerplate.go.txt
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


Expand All @@ -56,7 +57,7 @@ docker-build:
debug: manager
./hack/build-image.sh
release: manager test docker-build
kustomize build config/default -o deploy/s2ioperator.yaml
kubectl kustomize config > deploy/s2ioperator.yaml

install-travis:
chmod +x ./hack/*.sh
Expand Down
13 changes: 12 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
version: "1"

domain: kubesphere.io
repo: github.com/kubesphere/s2ioperator
resources:
- group: devops.kubesphere.io
kind: S2iBuilderTemplate
version: v1alpha1
- group: devops.kubesphere.io
kind: S2iBuilder
version: v1alpha1
- group: devops.kubesphere.io
kind: S2iRun
version: v1alpha1
version: "2"
35 changes: 21 additions & 14 deletions api/api-rules/violation_exceptions.list
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,EndpointSubset,NotReady
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
API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,EnvFrom
API rule violation: list_type_missing,k8s.io/api/core/v1,EphemeralContainerCommon,Ports
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
Expand All @@ -56,12 +64,14 @@ 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
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSelectorTerm,MatchFields
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSpec,PodCIDRs
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeSpec,Taints
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,Addresses
API rule violation: list_type_missing,k8s.io/api/core/v1,NodeStatus,Conditions
Expand Down Expand Up @@ -89,6 +99,7 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,PodPortForwardOptions,P
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
API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,Containers
API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,EphemeralContainers
API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,HostAliases
API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,ImagePullSecrets
API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,InitContainers
Expand All @@ -97,7 +108,9 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,Tolerations
API rule violation: list_type_missing,k8s.io/api/core/v1,PodSpec,Volumes
API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,Conditions
API rule violation: list_type_missing,k8s.io/api/core/v1,PodStatus,ContainerStatuses
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
Expand All @@ -118,7 +131,6 @@ API rule violation: list_type_missing,k8s.io/api/core/v1,ServiceAccountList,Item
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,Ports
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 @@ -131,31 +143,27 @@ API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIVe
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIVersions,Versions
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,CreateOptions,DryRun
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,DeleteOptions,DryRun
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,Initializers,Pending
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
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,Table,ColumnDefinitions
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,Table,Rows
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,TableRow,Cells
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,TableRow,Conditions
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,UpdateOptions,DryRun
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/runtime,RawExtension,Raw
API rule violation: list_type_missing,k8s.io/apimachinery/pkg/runtime,Unknown,Raw
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,CGroupLimits,CPUPeriod
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,CGroupLimits,CPUQuota
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,CGroupLimits,CPUShares
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,CGroupLimits,MemoryLimitBytes
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,CGroupLimits,MemorySwap
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,CGroupLimits,Parent
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,ContainerConfig,Env
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,ContainerConfig,Labels
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,DockerConfig,CAFile
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,DockerConfig,CertFile
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,DockerConfig,Endpoint
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,DockerConfig,KeyFile
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,DockerConfig,TLSVerify
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,DockerConfig,UseTLS
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iBuilderTemplateSpec,Parameters
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iConfig,CGroupLimits
API rule violation: names_match,github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1,S2iConfig,CallbackURL
Expand Down Expand Up @@ -201,7 +209,6 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEve
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,RawExtension,Raw
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentType
API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,Raw
Expand Down
23 changes: 17 additions & 6 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ package main

import (
"flag"
"github.com/kubesphere/s2ioperator/pkg/metrics"
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
"os"

"github.com/kubesphere/s2ioperator/pkg/metrics"

"github.com/kubesphere/s2ioperator/pkg/apis"
"github.com/kubesphere/s2ioperator/pkg/controller"
"github.com/kubesphere/s2ioperator/pkg/webhook"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand All @@ -46,7 +47,7 @@ func main() {
os.Exit(1)
}

// Create a new Cmd to provide shared dependencies and start components
// 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})
if err != nil {
Expand All @@ -70,12 +71,22 @@ func main() {
os.Exit(1)
}

log.Info("setting up webhooks")
if err := webhook.AddToManager(mgr); err != nil {
log.Error(err, "unable to register webhooks to the manager")
if err = (&v1alpha1.S2iBuilderTemplate{}).SetupWebhookWithManager(mgr); err != nil {
log.Error(err, "unable to create webhook", "webhook", "Captain")
os.Exit(1)
}

if err = (&v1alpha1.S2iBuilder{}).SetupWebhookWithManager(mgr); err != nil {
log.Error(err, "unable to create webhook", "webhook", "Captain")
os.Exit(1)
}

if err = (&v1alpha1.S2iRun{}).SetupWebhookWithManager(mgr); err != nil {
log.Error(err, "unable to create webhook", "webhook", "Captain")
os.Exit(1)
}


// Set up s2i metrics
log.Info("start collect s2i metrics")
go metrics.CollectS2iMetrics(mgr.GetClient())
Expand Down
23 changes: 23 additions & 0 deletions config/certmanager/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: cert-manager.io/v1alpha2
kind: Issuer
metadata:
name: s2i-selfsigned-issuer
namespace: kubesphere-devops-system
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: s2i-webhook-serving-cert # this name should match the one appeared in kustomizeconfig.yaml
namespace: kubesphere-devops-system
spec:
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
commonName: $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
dnsNames:
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
issuerRef:
kind: Issuer
name: s2i-selfsigned-issuer
secretName: s2i-webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
5 changes: 5 additions & 0 deletions config/certmanager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- certificate.yaml

configurations:
- kustomizeconfig.yaml
15 changes: 15 additions & 0 deletions config/certmanager/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
nameReference:
- kind: Issuer
group: cert-manager.io
fieldSpecs:
- kind: Certificate
group: cert-manager.io
path: spec/issuerRef/name

varReference:
- kind: Certificate
group: cert-manager.io
path: spec/commonName
- kind: Certificate
group: cert-manager.io
path: spec/dnsNames
Loading

0 comments on commit 9bf2b56

Please sign in to comment.