Skip to content

Commit

Permalink
Fix Function Controller manifests generation (#11455)
Browse files Browse the repository at this point in the history
* Fix Function Controller manifests generation

* Bump images

* Update README
  • Loading branch information
tgorgol committed Jun 16, 2021
1 parent 7933d4d commit 3d36a7b
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 314 deletions.
31 changes: 27 additions & 4 deletions components/function-controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ IMG ?= $(APP_NAME):latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,crdVersions=v1"

# 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

pull-licenses-local:
@echo "Omitting licenses will not be pulled."

Expand All @@ -31,20 +38,36 @@ test-local:

# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: generate-local
manifests: controller-gen-local generate-local
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=serverless webhook paths="./..." \
object:headerFile=hack/boilerplate.go.txt \
output:crd:artifacts:config=config/crd/bases \
output:rbac:artifacts:config=config/rbac \
output:webhook:artifacts:config=config/webhook

CONTROLLER_GEN := $(shell which controller-gen)

# Generate code
.PHONY: generate-local
generate-local:
generate-local: controller-gen-local
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."

# find or download controller-gen
# download controller-gen if necessary
.PHONY: controller-gen-local
controller-gen-local:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.9 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

.PHONY: build-image
build-image: build-function-webhook \
build-function-build-init \
Expand Down
2 changes: 1 addition & 1 deletion components/function-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The Function Controller requires the following components to be installed:

- [Istio](https://github.com/istio/istio/releases) (v1.4.3)
- [Docker registry](https://github.com/docker/distribution) (v2.7.1)
- [controller-gen](https://github.com/kubernetes-sigs/controller-tools/tree/master/cmd/controller-gen) (v0.2.4+)
- [controller-gen](https://github.com/kubernetes-sigs/controller-tools/tree/master/cmd/controller-gen) (v0.2.9)

## Development

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,61 +16,61 @@ spec:
singular: gitrepository
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.url
name: URL
type: string
- jsonPath: .spec.auth.type
name: Auth
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: GitRepository is the Schema for the gitrepositories API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
- additionalPrinterColumns:
- jsonPath: .spec.url
name: URL
type: string
- jsonPath: .spec.auth.type
name: Auth
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: GitRepository is the Schema for the gitrepositories API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: GitRepositorySpec defines the desired state of GitRepository
properties:
auth:
description: Auth is the optional definition of authentication that
should be used for repository operations
properties:
secretName:
description: SecretName is the name of Kubernetes Secret containing
credentials used for authentication
type: string
type:
description: Type is the type of authentication
enum:
- basic
- key
type: string
required:
- secretName
- type
type: object
url:
description: URL is the address of GIT repository
type: string
required:
- url
type: object
type: object
served: true
storage: true
subresources: {}
type: string
metadata:
type: object
spec:
description: GitRepositorySpec defines the desired state of GitRepository
properties:
auth:
description: Auth is the optional definition of authentication that
should be used for repository operations
properties:
secretName:
description: SecretName is the name of Kubernetes Secret containing
credentials used for authentication
type: string
type:
description: Type is the type of authentication
enum:
- basic
- key
type: string
required:
- secretName
- type
type: object
url:
description: URL is the address of GIT repository
type: string
required:
- url
type: object
type: object
served: true
storage: true
subresources: {}
status:
acceptedNames:
kind: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (r *FunctionReconciler) updateStatus(ctx context.Context, result ctrl.Resul
}

service.Status.Source = instance.Spec.Source
service.Status.Runtime = instance.Spec.Runtime
service.Status.Runtime = serverlessv1alpha1.RuntimeExtended(instance.Spec.Runtime)

if err := r.client.Status().Update(ctx, service); err != nil {
return ctrl.Result{}, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (r *FunctionReconciler) isOnSourceChange(instance *serverlessv1alpha1.Funct
return instance.Status.Commit == "" ||
commit != instance.Status.Commit ||
instance.Spec.Reference != instance.Status.Reference ||
instance.Spec.Runtime != instance.Status.Runtime ||
serverlessv1alpha1.RuntimeExtended(instance.Spec.Runtime) != instance.Status.Runtime ||
instance.Spec.BaseDir != instance.Status.BaseDir ||
r.getConditionStatus(instance.Status.Conditions, serverlessv1alpha1.ConditionConfigurationReady) == corev1.ConditionFalse
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Test_isOnSourceChange(t *testing.T) {
Reference: "1",
},
Commit: "1",
Runtime: v1alpha1.Nodejs12,
Runtime: v1alpha1.RuntimeExtendedNodejs12,
},
},
revision: "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@ import (

type SourceType string

// +kubebuilder:validation:Enum=nodejs12;nodejs14;python38

type Runtime string

const (
SourceTypeGit SourceType = "git"
)

// Runtime enumerates runtimes that are currently supported by Function Controller
// It is a subset of RuntimeExtended
// +kubebuilder:validation:Enum=nodejs12;nodejs14;python38
type Runtime string

const (
Nodejs12 Runtime = "nodejs12"
Nodejs14 Runtime = "nodejs14"
Python38 Runtime = "python38"
)

// RuntimeExtended enumerates runtimes that are either currently supported or
// no longer supported but there still might be "read-only" Functions using them
// +kubebuilder:validation:Enum=nodejs12;nodejs14;python38;nodejs10
type RuntimeExtended string

const (
RuntimeExtendedNodejs10 RuntimeExtended = "nodejs10"
RuntimeExtendedNodejs12 RuntimeExtended = "nodejs12"
RuntimeExtendedNodejs14 RuntimeExtended = "nodejs14"
RuntimeExtendedPython38 RuntimeExtended = "python38"
)

const (
ReplicasPresetLabel = "serverless.kyma-project.io/replicas-preset"
FunctionResourcesPresetLabel = "serverless.kyma-project.io/function-resources-preset"
Expand Down Expand Up @@ -113,13 +126,13 @@ type Condition struct {
Message string `json:"message,omitempty"`
}

// FunctionStatus defines the observed state of FuncSONPath: .status.phase
// FunctionStatus defines the observed state of Function
type FunctionStatus struct {
Conditions []Condition `json:"conditions,omitempty"`
Repository `json:",inline,omitempty"`
Commit string `json:"commit,omitempty"`
Source string `json:"source,omitempty"`
Runtime Runtime `json:"runtime,omitempty"`
Commit string `json:"commit,omitempty"`
Source string `json:"source,omitempty"`
Runtime RuntimeExtended `json:"runtime,omitempty"`
}

type Repository struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ spec:
type: object
type: object
runtime:
description: Runtime enumerates runtimes that are currently supported
by Function Controller It is a subset of RuntimeExtended
enum:
- nodejs12
- nodejs14
Expand All @@ -244,8 +246,7 @@ spec:
- source
type: object
status:
description: 'FunctionStatus defines the observed state of FuncSONPath:
.status.phase'
description: FunctionStatus defines the observed state of Function
properties:
baseDir:
type: string
Expand Down Expand Up @@ -273,11 +274,14 @@ spec:
reference:
type: string
runtime:
description: RuntimeExtended enumerates runtimes that are either currently
supported or no longer supported but there still might be "read-only"
Functions using them
enum:
- nodejs10
- nodejs12
- nodejs14
- python38
- nodejs10
type: string
source:
type: string
Expand Down
6 changes: 3 additions & 3 deletions resources/serverless/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ global:
images:
manager:
repository: "eu.gcr.io/kyma-project/function-controller"
tag: "a9278e66"
tag: "PR-11455"
pullPolicy: IfNotPresent
runtimes:
nodejs12:
Expand Down Expand Up @@ -162,7 +162,7 @@ containers:
functionBuildExecutorImage:
value: gcr.io/kaniko-project/executor:v1.5.1
functionBuildRepoFetcherImage:
value: eu.gcr.io/kyma-project/function-build-init:a9278e66
value: eu.gcr.io/kyma-project/function-build-init:PR-11455
functionBuildMaxSimultaneousJobs:
value: "5"
logLevel:
Expand Down Expand Up @@ -243,7 +243,7 @@ webhook:
fullnameOverride: "serverless-webhook"
image:
repository: "eu.gcr.io/kyma-project/function-webhook"
tag: "a9278e66"
tag: "PR-11455"

k3s-tests:
enabled: false # this chart is installed manually, do not flip this value

0 comments on commit 3d36a7b

Please sign in to comment.