Skip to content

Commit

Permalink
Add support for serviceAccountName on deploy
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 12, 2023
1 parent 529957e commit bd360eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/functions/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,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 bd360eb

Please sign in to comment.