Skip to content

Commit

Permalink
Add support for serviceAccountName on deploy (#1811)
Browse files Browse the repository at this point in the history
This allows setting the service account for the resulting knative
service, which must pre-exist in the namespace to let the deployment
succeed.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
  • Loading branch information
saschagrunert committed Jun 19, 2023
1 parent 3d11766 commit c1a90f6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/reference/func_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ subsequent deployments.

The Kubernetes namespace where your function will be deployed.


### `serviceAccountName`

The name of the service account used for the function pod. The service account
must exist in the namespace to succeed.

More info: https://k8s.io/docs/tasks/configure-pod-container/configure-service-account

### `options`
Options allows you to set specific configuration for the deployed function, allowing you to tweak Knative Service options related to autoscaling and other properties. If these options are not set, the Knative defaults will be used.
- `scale`
Expand Down
6 changes: 6 additions & 0 deletions pkg/functions/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ type DeploySpec struct {

// Health endpoints specified by the language pack
HealthEndpoints HealthEndpoints `yaml:"healthEndpoints,omitempty"`

// ServiceAccountName is the name of the service account used for the
// function pod. The service account must exist in the namespace to
// succeed.
// More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
ServiceAccountName string `yaml:"serviceAccountName,omitempty"`
}

// HealthEndpoints specify the liveness and readiness endpoints for a Runtime
Expand Down
3 changes: 2 additions & 1 deletion pkg/knative/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ func generateNewService(f fn.Function, decorator DeployDecorator) (*v1.Service,
Containers: []corev1.Container{
container,
},
Volumes: newVolumes,
ServiceAccountName: f.Deploy.ServiceAccountName,
Volumes: newVolumes,
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions schema/func_yaml-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/HealthEndpoints",
"description": "Health endpoints specified by the language pack"
},
"serviceAccountName": {
"type": "string",
"description": "ServiceAccountName is the name of the service account used for the\nfunction pod. The service account must exist in the namespace to\nsucceed.\nMore info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/"
}
},
"additionalProperties": false,
Expand Down

0 comments on commit c1a90f6

Please sign in to comment.