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
PostgresImage string `json:"postgres_image,omitempty"`
// postgres init image
PostgresInitImage string `json:"postgres_init_image,omitempty"`
// storage class
StorageClass string `json:"storageClass,omitempty"`

View File

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

View File

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

View File

@@ -1228,6 +1228,7 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
logSearchStorageClass := "" // Default is ""
logSearchImage := ""
logSearchPgImage := ""
logSearchPgInitImage := ""
if tenantReq.LogSearchConfiguration != nil {
if tenantReq.LogSearchConfiguration.StorageSize != nil {
@@ -1245,6 +1246,9 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
if tenantReq.LogSearchConfiguration.PostgresImage != "" {
logSearchPgImage = tenantReq.LogSearchConfiguration.PostgresImage
}
if tenantReq.LogSearchConfiguration.PostgresInitImage != "" {
logSearchPgInitImage = tenantReq.LogSearchConfiguration.PostgresInitImage
}
}
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 != "" {
minInst.Spec.Log.Image = logSearchImage
}
if logSearchPgImage != "" {
minInst.Spec.Log.Db.Image = logSearchPgImage
}
if logSearchPgInitImage != "" {
minInst.Spec.Log.Db.InitImage = logSearchPgInitImage
}
prometheusDiskSpace := 5 // Default is 5 by API
prometheusStorageClass := "" // Default is ""
prometheusImage := "" // Default is ""
prometheusDiskSpace := 5 // Default is 5 by API
prometheusStorageClass := "" // Default is ""
prometheusImage := "" // Default is ""
prometheusSidecardImage := "" // Default is ""
prometheusInitImage := "" // Default is ""
if tenantReq.PrometheusConfiguration != nil {
if tenantReq.PrometheusConfiguration.StorageSize != nil {
@@ -1303,6 +1313,12 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
if 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{
@@ -1312,6 +1328,12 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
if 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 tenantReq.PrometheusConfiguration != nil && tenantReq.PrometheusConfiguration.SecurityContext != nil {
sc := tenantReq.PrometheusConfiguration.SecurityContext

View File

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

View File

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

View File

@@ -56,8 +56,11 @@ interface IConfigureProps {
logSearchImage: string;
kesImage: string;
logSearchPostgresImage: string;
logSearchPostgresInitImage: string;
prometheusSelectedStorageClass: string;
prometheusImage: string;
prometheusSidecarImage: string;
prometheusInitImage: string;
selectedStorageClass: string;
}
@@ -88,11 +91,14 @@ const Configure = ({
logSearchImage,
kesImage,
logSearchPostgresImage,
logSearchPostgresInitImage,
prometheusVolumeSize,
prometheusSizeFactor,
logSearchSelectedStorageClass,
prometheusSelectedStorageClass,
prometheusImage,
prometheusSidecarImage,
prometheusInitImage,
updateAddField,
isPageValid,
selectedStorageClass,
@@ -185,6 +191,14 @@ const Configure = ({
customPatternMessage:
"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",
required: false,
@@ -193,6 +207,22 @@ const Configure = ({
customPatternMessage:
"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) {
customAccountValidation = [
@@ -227,7 +257,10 @@ const Configure = ({
logSearchImage,
kesImage,
logSearchPostgresImage,
logSearchPostgresInitImage,
prometheusImage,
prometheusSidecarImage,
prometheusInitImage,
customDockerhub,
imageRegistry,
imageRegistryUsername,
@@ -352,6 +385,20 @@ const Configure = ({
placeholder="E.g. library/postgres:13"
/>
</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}>
<InputBoxWrapper
id="prometheusImage"
@@ -366,6 +413,34 @@ const Configure = ({
placeholder="E.g. quay.io/prometheus/prometheus:latest"
/>
</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>
)}
{customImage && (
@@ -620,9 +695,15 @@ const mapState = (state: AppState) => ({
kesImage: state.tenants.createTenant.fields.configure.kesImage,
logSearchPostgresImage:
state.tenants.createTenant.fields.configure.logSearchPostgresImage,
logSearchPostgresInitImage:
state.tenants.createTenant.fields.configure.logSearchPostgresInitImage,
prometheusSelectedStorageClass:
state.tenants.createTenant.fields.configure.prometheusSelectedStorageClass,
prometheusImage: state.tenants.createTenant.fields.configure.prometheusImage,
prometheusSidecarImage:
state.tenants.createTenant.fields.configure.prometheusSidecarImage,
prometheusInitImage:
state.tenants.createTenant.fields.configure.prometheusInitImage,
selectedStorageClass:
state.tenants.createTenant.fields.nameTenant.selectedStorageClass,
});

View File

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

View File

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

View File

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