Add tenant runtimeclass (#2565)

This commit is contained in:
Allan Roger Reid
2023-01-12 14:27:53 -08:00
committed by GitHub
parent 37db97dba9
commit 6a88d26054
5 changed files with 45 additions and 15 deletions

View File

@@ -48,6 +48,9 @@ type Pool struct {
// resources
Resources *PoolResources `json:"resources,omitempty"`
// runtime class name
RuntimeClassName string `json:"runtimeClassName,omitempty"`
// security context
SecurityContext *SecurityContext `json:"securityContext,omitempty"`

View File

@@ -4043,6 +4043,9 @@ func init() {
"resources": {
"$ref": "#/definitions/poolResources"
},
"runtimeClassName": {
"type": "string"
},
"securityContext": {
"type": "object",
"$ref": "#/definitions/securityContext"
@@ -9976,6 +9979,9 @@ func init() {
"resources": {
"$ref": "#/definitions/poolResources"
},
"runtimeClassName": {
"type": "string"
},
"securityContext": {
"type": "object",
"$ref": "#/definitions/securityContext"

View File

@@ -2270,9 +2270,10 @@ func parseTenantPoolRequest(poolParams *models.Pool) (*miniov2.Pool, error) {
Requests: resourcesRequests,
Limits: resourcesLimits,
},
NodeSelector: poolParams.NodeSelector,
Affinity: affinity,
Tolerations: tolerations,
NodeSelector: poolParams.NodeSelector,
Affinity: affinity,
Tolerations: tolerations,
RuntimeClassName: &poolParams.RuntimeClassName,
}
// if security context for Tenant is present, configure it.
if poolParams.SecurityContext != nil {
@@ -2493,6 +2494,11 @@ func parseTenantPool(pool *miniov2.Pool) *models.Pool {
}
}
var runtimeClassName string
if pool.RuntimeClassName != nil {
runtimeClassName = *pool.RuntimeClassName
}
poolModel := &models.Pool{
Name: pool.Name,
Servers: swag.Int64(int64(pool.Servers)),
@@ -2501,11 +2507,12 @@ func parseTenantPool(pool *miniov2.Pool) *models.Pool {
Size: size,
StorageClassName: storageClassName,
},
NodeSelector: pool.NodeSelector,
Resources: resources,
Affinity: affinity,
Tolerations: tolerations,
SecurityContext: &securityContext,
NodeSelector: pool.NodeSelector,
Resources: resources,
Affinity: affinity,
Tolerations: tolerations,
SecurityContext: &securityContext,
RuntimeClassName: runtimeClassName,
}
return poolModel
}

View File

@@ -370,7 +370,7 @@ export MINIO_SECRET_KEY=minio123
}
}
func NoTestTenantInfo(t *testing.T) {
func Test_TenantInfo(t *testing.T) {
testTimeStamp := metav1.Now()
type args struct {
minioTenant *miniov2.Tenant
@@ -405,6 +405,7 @@ func NoTestTenantInfo(t *testing.T) {
StorageClassName: swag.String("standard"),
},
},
RuntimeClassName: swag.String(""),
},
},
@@ -422,7 +423,12 @@ func NoTestTenantInfo(t *testing.T) {
CurrentState: "ready",
Pools: []*models.Pool{
{
Name: "pool1",
Name: "pool1",
SecurityContext: &models.SecurityContext{
RunAsGroup: nil,
RunAsNonRoot: nil,
RunAsUser: nil,
},
Servers: swag.Int64(int64(2)),
VolumesPerServer: swag.Int32(4),
VolumeConfiguration: &models.PoolVolumeConfiguration{
@@ -470,6 +476,7 @@ func NoTestTenantInfo(t *testing.T) {
StorageClassName: swag.String("standard"),
},
},
RuntimeClassName: swag.String(""),
},
},
Image: "minio/minio:RELEASE.2020-06-14T18-32-17Z",
@@ -487,7 +494,12 @@ func NoTestTenantInfo(t *testing.T) {
CurrentState: "ready",
Pools: []*models.Pool{
{
Name: "pool1",
Name: "pool1",
SecurityContext: &models.SecurityContext{
RunAsGroup: nil,
RunAsNonRoot: nil,
RunAsUser: nil,
},
Servers: swag.Int64(int64(2)),
VolumesPerServer: swag.Int32(4),
VolumeConfiguration: &models.PoolVolumeConfiguration{
@@ -1012,7 +1024,7 @@ func Test_UpdateTenantAction(t *testing.T) {
},
params: operator_api.UpdateTenantParams{
Body: &models.UpdateTenantRequest{
Image: "minio/minio:RELEASE.2020-06-03T22-13-49Z",
Image: "minio/minio:RELEASE.2023-01-06T18-11-18Z",
},
},
},
@@ -1037,7 +1049,7 @@ func Test_UpdateTenantAction(t *testing.T) {
},
params: operator_api.UpdateTenantParams{
Body: &models.UpdateTenantRequest{
Image: "minio/minio:RELEASE.2020-06-03T22-13-49Z",
Image: "minio/minio:RELEASE.2023-01-06T18-11-18Z",
},
},
},
@@ -1063,7 +1075,7 @@ func Test_UpdateTenantAction(t *testing.T) {
params: operator_api.UpdateTenantParams{
Tenant: "minio-tenant",
Body: &models.UpdateTenantRequest{
Image: "minio/minio:RELEASE.2020-06-03T22-13-49Z",
Image: "minio/minio:RELEASE.2023-01-06T18-11-18Z",
},
},
},

View File

@@ -2610,6 +2610,8 @@ definitions:
https://kubernetes.io/docs/concepts/configuration/assign-pod-node/"
affinity:
$ref: "#/definitions/poolAffinity"
runtimeClassName:
type: string
tolerations:
$ref: "#/definitions/poolTolerations"
securityContext:
@@ -3750,4 +3752,4 @@ definitions:
redirect:
type: string
displayName:
type: string
type: string