Add support for additional images (#1003)

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2021-09-01 20:23:56 -07:00
committed by GitHub
parent 1ba2627810
commit 6cf657a0e1
10 changed files with 161 additions and 3 deletions

View File

@@ -40,6 +40,9 @@ type LogSearchConfiguration struct {
// postgres image // postgres image
PostgresImage string `json:"postgres_image,omitempty"` PostgresImage string `json:"postgres_image,omitempty"`
// postgres init image
PostgresInitImage string `json:"postgres_init_image,omitempty"`
// storage class // storage class
StorageClass string `json:"storageClass,omitempty"` StorageClass string `json:"storageClass,omitempty"`

View File

@@ -38,9 +38,15 @@ type PrometheusConfiguration struct {
// image // image
Image string `json:"image,omitempty"` Image string `json:"image,omitempty"`
// init image
InitImage string `json:"init_image,omitempty"`
// security context // security context
SecurityContext *SecurityContext `json:"securityContext,omitempty"` SecurityContext *SecurityContext `json:"securityContext,omitempty"`
// sidecar image
SidecarImage string `json:"sidecar_image,omitempty"`
// storage class // storage class
StorageClass string `json:"storageClass,omitempty"` StorageClass string `json:"storageClass,omitempty"`

View File

@@ -2058,6 +2058,9 @@ func init() {
"postgres_image": { "postgres_image": {
"type": "string" "type": "string"
}, },
"postgres_init_image": {
"type": "string"
},
"storageClass": { "storageClass": {
"type": "string", "type": "string",
"default": "" "default": ""
@@ -2611,10 +2614,16 @@ func init() {
"image": { "image": {
"type": "string" "type": "string"
}, },
"init_image": {
"type": "string"
},
"securityContext": { "securityContext": {
"type": "object", "type": "object",
"$ref": "#/definitions/securityContext" "$ref": "#/definitions/securityContext"
}, },
"sidecar_image": {
"type": "string"
},
"storageClass": { "storageClass": {
"type": "string", "type": "string",
"default": "" "default": ""
@@ -5755,6 +5764,9 @@ func init() {
"postgres_image": { "postgres_image": {
"type": "string" "type": "string"
}, },
"postgres_init_image": {
"type": "string"
},
"storageClass": { "storageClass": {
"type": "string", "type": "string",
"default": "" "default": ""
@@ -6173,10 +6185,16 @@ func init() {
"image": { "image": {
"type": "string" "type": "string"
}, },
"init_image": {
"type": "string"
},
"securityContext": { "securityContext": {
"type": "object", "type": "object",
"$ref": "#/definitions/securityContext" "$ref": "#/definitions/securityContext"
}, },
"sidecar_image": {
"type": "string"
},
"storageClass": { "storageClass": {
"type": "string", "type": "string",
"default": "" "default": ""

View File

@@ -1228,6 +1228,7 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
logSearchStorageClass := "" // Default is "" logSearchStorageClass := "" // Default is ""
logSearchImage := "" logSearchImage := ""
logSearchPgImage := "" logSearchPgImage := ""
logSearchPgInitImage := ""
if tenantReq.LogSearchConfiguration != nil { if tenantReq.LogSearchConfiguration != nil {
if tenantReq.LogSearchConfiguration.StorageSize != nil { if tenantReq.LogSearchConfiguration.StorageSize != nil {
@@ -1245,6 +1246,9 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
if tenantReq.LogSearchConfiguration.PostgresImage != "" { if tenantReq.LogSearchConfiguration.PostgresImage != "" {
logSearchPgImage = tenantReq.LogSearchConfiguration.PostgresImage logSearchPgImage = tenantReq.LogSearchConfiguration.PostgresImage
} }
if tenantReq.LogSearchConfiguration.PostgresInitImage != "" {
logSearchPgInitImage = tenantReq.LogSearchConfiguration.PostgresInitImage
}
} }
logSearchDiskSpace := resource.NewQuantity(diskSpaceFromAPI, resource.DecimalExponent) logSearchDiskSpace := resource.NewQuantity(diskSpaceFromAPI, resource.DecimalExponent)
@@ -1276,16 +1280,22 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
}, },
}, },
} }
// set log search images if any
if logSearchImage != "" { if logSearchImage != "" {
minInst.Spec.Log.Image = logSearchImage minInst.Spec.Log.Image = logSearchImage
} }
if logSearchPgImage != "" { if logSearchPgImage != "" {
minInst.Spec.Log.Db.Image = logSearchPgImage minInst.Spec.Log.Db.Image = logSearchPgImage
} }
if logSearchPgInitImage != "" {
minInst.Spec.Log.Db.InitImage = logSearchPgInitImage
}
prometheusDiskSpace := 5 // Default is 5 by API prometheusDiskSpace := 5 // Default is 5 by API
prometheusStorageClass := "" // Default is "" prometheusStorageClass := "" // Default is ""
prometheusImage := "" // Default is "" prometheusImage := "" // Default is ""
prometheusSidecardImage := "" // Default is ""
prometheusInitImage := "" // Default is ""
if tenantReq.PrometheusConfiguration != nil { if tenantReq.PrometheusConfiguration != nil {
if tenantReq.PrometheusConfiguration.StorageSize != nil { if tenantReq.PrometheusConfiguration.StorageSize != nil {
@@ -1303,6 +1313,12 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
if tenantReq.PrometheusConfiguration.Image != "" { if tenantReq.PrometheusConfiguration.Image != "" {
prometheusImage = tenantReq.PrometheusConfiguration.Image prometheusImage = tenantReq.PrometheusConfiguration.Image
} }
if tenantReq.PrometheusConfiguration.SidecarImage != "" {
prometheusSidecardImage = tenantReq.PrometheusConfiguration.SidecarImage
}
if tenantReq.PrometheusConfiguration.InitImage != "" {
prometheusInitImage = tenantReq.PrometheusConfiguration.InitImage
}
} }
minInst.Spec.Prometheus = &miniov2.PrometheusConfig{ minInst.Spec.Prometheus = &miniov2.PrometheusConfig{
@@ -1312,6 +1328,12 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
if prometheusImage != "" { if prometheusImage != "" {
minInst.Spec.Prometheus.Image = prometheusImage minInst.Spec.Prometheus.Image = prometheusImage
} }
if prometheusSidecardImage != "" {
minInst.Spec.Prometheus.SideCarImage = prometheusSidecardImage
}
if prometheusInitImage != "" {
minInst.Spec.Prometheus.InitImage = prometheusInitImage
}
// if security context for prometheus is present, configure it. // if security context for prometheus is present, configure it.
if tenantReq.PrometheusConfiguration != nil && tenantReq.PrometheusConfiguration.SecurityContext != nil { if tenantReq.PrometheusConfiguration != nil && tenantReq.PrometheusConfiguration.SecurityContext != nil {
sc := tenantReq.PrometheusConfiguration.SecurityContext sc := tenantReq.PrometheusConfiguration.SecurityContext

View File

@@ -369,12 +369,15 @@ export interface LogSearchConfiguration {
storageSize?: number; storageSize?: number;
image: string; image: string;
postgres_image: string; postgres_image: string;
postgres_init_image: string;
} }
export interface PrometheusConfiguration { export interface PrometheusConfiguration {
storageClass?: string; storageClass?: string;
storageSize?: number; storageSize?: number;
image: string; image: string;
sidecar_image: string;
init_image: string;
} }
export interface AffinityConfiguration { export interface AffinityConfiguration {

View File

@@ -175,7 +175,11 @@ const AddTenant = ({
const logSearchImage = fields.configure.logSearchImage; const logSearchImage = fields.configure.logSearchImage;
const kesImage = fields.configure.kesImage; const kesImage = fields.configure.kesImage;
const logSearchPostgresImage = fields.configure.logSearchPostgresImage; const logSearchPostgresImage = fields.configure.logSearchPostgresImage;
const logSearchPostgresInitImage =
fields.configure.logSearchPostgresInitImage;
const prometheusImage = fields.configure.prometheusImage; const prometheusImage = fields.configure.prometheusImage;
const prometheusSidecarImage = fields.configure.prometheusSidecarImage;
const prometheusInitImage = fields.configure.prometheusInitImage;
const prometheusSelectedStorageClass = const prometheusSelectedStorageClass =
fields.configure.prometheusSelectedStorageClass; fields.configure.prometheusSelectedStorageClass;
const prometheusVolumeSize = fields.configure.prometheusVolumeSize; const prometheusVolumeSize = fields.configure.prometheusVolumeSize;
@@ -264,6 +268,7 @@ const AddTenant = ({
storageSize: parseInt(logSearchVolumeSize), storageSize: parseInt(logSearchVolumeSize),
image: logSearchImage, image: logSearchImage,
postgres_image: logSearchPostgresImage, postgres_image: logSearchPostgresImage,
postgres_init_image: logSearchPostgresInitImage,
}, },
}; };
} else { } else {
@@ -272,6 +277,7 @@ const AddTenant = ({
logSearchConfiguration: { logSearchConfiguration: {
image: logSearchImage, image: logSearchImage,
postgres_image: logSearchPostgresImage, postgres_image: logSearchPostgresImage,
postgres_init_image: logSearchPostgresInitImage,
}, },
}; };
} }
@@ -283,6 +289,8 @@ const AddTenant = ({
storageClass: prometheusSelectedStorageClass, storageClass: prometheusSelectedStorageClass,
storageSize: parseInt(prometheusVolumeSize), storageSize: parseInt(prometheusVolumeSize),
image: prometheusImage, image: prometheusImage,
sidecar_image: prometheusSidecarImage,
init_image: prometheusInitImage,
}, },
}; };
} else { } else {
@@ -290,6 +298,8 @@ const AddTenant = ({
...dataSend, ...dataSend,
prometheusConfiguration: { prometheusConfiguration: {
image: prometheusImage, image: prometheusImage,
sidecar_image: prometheusSidecarImage,
init_image: prometheusInitImage,
}, },
}; };
} }

View File

@@ -56,8 +56,11 @@ interface IConfigureProps {
logSearchImage: string; logSearchImage: string;
kesImage: string; kesImage: string;
logSearchPostgresImage: string; logSearchPostgresImage: string;
logSearchPostgresInitImage: string;
prometheusSelectedStorageClass: string; prometheusSelectedStorageClass: string;
prometheusImage: string; prometheusImage: string;
prometheusSidecarImage: string;
prometheusInitImage: string;
selectedStorageClass: string; selectedStorageClass: string;
} }
@@ -88,11 +91,14 @@ const Configure = ({
logSearchImage, logSearchImage,
kesImage, kesImage,
logSearchPostgresImage, logSearchPostgresImage,
logSearchPostgresInitImage,
prometheusVolumeSize, prometheusVolumeSize,
prometheusSizeFactor, prometheusSizeFactor,
logSearchSelectedStorageClass, logSearchSelectedStorageClass,
prometheusSelectedStorageClass, prometheusSelectedStorageClass,
prometheusImage, prometheusImage,
prometheusSidecarImage,
prometheusInitImage,
updateAddField, updateAddField,
isPageValid, isPageValid,
selectedStorageClass, selectedStorageClass,
@@ -185,6 +191,14 @@ const Configure = ({
customPatternMessage: customPatternMessage:
"Format must be of form: 'library/postgres:VERSION'", "Format must be of form: 'library/postgres:VERSION'",
}, },
{
fieldKey: "logSearchPostgresInitImage",
required: false,
value: logSearchPostgresInitImage,
pattern: /^((.*?)\/(.*?):(.+))$/,
customPatternMessage:
"Format must be of form: 'library/busybox:VERSION'",
},
{ {
fieldKey: "prometheusImage", fieldKey: "prometheusImage",
required: false, required: false,
@@ -193,6 +207,22 @@ const Configure = ({
customPatternMessage: customPatternMessage:
"Format must be of form: 'minio/prometheus:VERSION'", "Format must be of form: 'minio/prometheus:VERSION'",
}, },
{
fieldKey: "prometheusSidecarImage",
required: false,
value: prometheusSidecarImage,
pattern: /^((.*?)\/(.*?):(.+))$/,
customPatternMessage:
"Format must be of form: 'project/container:VERSION'",
},
{
fieldKey: "prometheusInitImage",
required: false,
value: prometheusInitImage,
pattern: /^((.*?)\/(.*?):(.+))$/,
customPatternMessage:
"Format must be of form: 'library/busybox:VERSION'",
},
]; ];
if (customDockerhub) { if (customDockerhub) {
customAccountValidation = [ customAccountValidation = [
@@ -227,7 +257,10 @@ const Configure = ({
logSearchImage, logSearchImage,
kesImage, kesImage,
logSearchPostgresImage, logSearchPostgresImage,
logSearchPostgresInitImage,
prometheusImage, prometheusImage,
prometheusSidecarImage,
prometheusInitImage,
customDockerhub, customDockerhub,
imageRegistry, imageRegistry,
imageRegistryUsername, imageRegistryUsername,
@@ -352,6 +385,20 @@ const Configure = ({
placeholder="E.g. library/postgres:13" placeholder="E.g. library/postgres:13"
/> />
</Grid> </Grid>
<Grid item xs={12}>
<InputBoxWrapper
id="logSearchPostgresInitImage"
name="logSearchPostgresInitImage"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField("logSearchPostgresInitImage", e.target.value);
cleanValidation("logSearchPostgresInitImage");
}}
label="Log Search Postgres's Init Image"
value={logSearchPostgresInitImage}
error={validationErrors["logSearchPostgresInitImage"] || ""}
placeholder="E.g. library/busybox:1.33.1"
/>
</Grid>
<Grid item xs={12}> <Grid item xs={12}>
<InputBoxWrapper <InputBoxWrapper
id="prometheusImage" id="prometheusImage"
@@ -366,6 +413,34 @@ const Configure = ({
placeholder="E.g. quay.io/prometheus/prometheus:latest" placeholder="E.g. quay.io/prometheus/prometheus:latest"
/> />
</Grid> </Grid>
<Grid item xs={12}>
<InputBoxWrapper
id="prometheusSidecarImage"
name="prometheusSidecarImage"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField("prometheusSidecarImage", e.target.value);
cleanValidation("prometheusSidecarImage");
}}
label="Prometheus Sidecar Image"
value={prometheusSidecarImage}
error={validationErrors["prometheusSidecarImage"] || ""}
placeholder="E.g. quay.io/prometheus/prometheus:latest"
/>
</Grid>
<Grid item xs={12}>
<InputBoxWrapper
id="prometheusInitImage"
name="prometheusInitImage"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField("prometheusInitImage", e.target.value);
cleanValidation("prometheusInitImage");
}}
label="Prometheus Init Image"
value={prometheusInitImage}
error={validationErrors["prometheusInitImage"] || ""}
placeholder="E.g. quay.io/prometheus/prometheus:latest"
/>
</Grid>
</Fragment> </Fragment>
)} )}
{customImage && ( {customImage && (
@@ -620,9 +695,15 @@ const mapState = (state: AppState) => ({
kesImage: state.tenants.createTenant.fields.configure.kesImage, kesImage: state.tenants.createTenant.fields.configure.kesImage,
logSearchPostgresImage: logSearchPostgresImage:
state.tenants.createTenant.fields.configure.logSearchPostgresImage, state.tenants.createTenant.fields.configure.logSearchPostgresImage,
logSearchPostgresInitImage:
state.tenants.createTenant.fields.configure.logSearchPostgresInitImage,
prometheusSelectedStorageClass: prometheusSelectedStorageClass:
state.tenants.createTenant.fields.configure.prometheusSelectedStorageClass, state.tenants.createTenant.fields.configure.prometheusSelectedStorageClass,
prometheusImage: state.tenants.createTenant.fields.configure.prometheusImage, prometheusImage: state.tenants.createTenant.fields.configure.prometheusImage,
prometheusSidecarImage:
state.tenants.createTenant.fields.configure.prometheusSidecarImage,
prometheusInitImage:
state.tenants.createTenant.fields.configure.prometheusInitImage,
selectedStorageClass: selectedStorageClass:
state.tenants.createTenant.fields.nameTenant.selectedStorageClass, state.tenants.createTenant.fields.nameTenant.selectedStorageClass,
}); });

View File

@@ -76,11 +76,14 @@ const initialState: ITenantState = {
logSearchImage: "", logSearchImage: "",
kesImage: "", kesImage: "",
logSearchPostgresImage: "", logSearchPostgresImage: "",
logSearchPostgresInitImage: "",
prometheusVolumeSize: "5", prometheusVolumeSize: "5",
prometheusSizeFactor: "Gi", prometheusSizeFactor: "Gi",
logSearchSelectedStorageClass: "", logSearchSelectedStorageClass: "",
prometheusSelectedStorageClass: "", prometheusSelectedStorageClass: "",
prometheusImage: "", prometheusImage: "",
prometheusSidecarImage: "",
prometheusInitImage: "",
}, },
identityProvider: { identityProvider: {
idpSelection: "Built-in", idpSelection: "Built-in",
@@ -544,10 +547,13 @@ export function tenantsReducer(
logSearchImage: "", logSearchImage: "",
kesImage: "", kesImage: "",
logSearchPostgresImage: "", logSearchPostgresImage: "",
logSearchPostgresInitImage: "",
prometheusVolumeSize: "5", prometheusVolumeSize: "5",
prometheusSizeFactor: "Gi", prometheusSizeFactor: "Gi",
prometheusSelectedStorageClass: "", prometheusSelectedStorageClass: "",
prometheusImage: "", prometheusImage: "",
prometheusSidecarImage: "",
prometheusInitImage: "",
}, },
identityProvider: { identityProvider: {
idpSelection: "Built-in", idpSelection: "Built-in",

View File

@@ -138,10 +138,13 @@ export interface IConfigureFields {
logSearchImage: string; logSearchImage: string;
kesImage: string; kesImage: string;
logSearchPostgresImage: string; logSearchPostgresImage: string;
logSearchPostgresInitImage: string;
prometheusVolumeSize: string; prometheusVolumeSize: string;
prometheusSizeFactor: string; prometheusSizeFactor: string;
prometheusSelectedStorageClass: string; prometheusSelectedStorageClass: string;
prometheusImage: string; prometheusImage: string;
prometheusSidecarImage: string;
prometheusInitImage: string;
} }
export interface IIdentityProviderFields { export interface IIdentityProviderFields {

View File

@@ -1306,6 +1306,8 @@ definitions:
type: string type: string
postgres_image: postgres_image:
type: string type: string
postgres_init_image:
type: string
prometheusConfiguration: prometheusConfiguration:
type: object type: object
properties: properties:
@@ -1317,6 +1319,10 @@ definitions:
default: 5 default: 5
image: image:
type: string type: string
sidecar_image:
type: string
init_image:
type: string
securityContext: securityContext:
type: object type: object
$ref: '#/definitions/securityContext' $ref: '#/definitions/securityContext'