[build] Include serverless config files in distribution (#155284)

This includes the serverless configuration files required for running
the `--serverless` CLI in our serverless distribution.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Jon 2023-04-25 12:34:32 -05:00 committed by GitHub
parent 13fd4f0847
commit 416940cec6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 71 additions and 5 deletions

View file

@ -30,6 +30,7 @@ if is_pr_with_label "ci:build-cloud-image"; then
--docker-push \
--skip-docker-ubi \
--skip-docker-ubuntu \
--skip-docker-serverless \
--skip-docker-contexts
docker logout docker.elastic.co

View file

@ -26,17 +26,18 @@ node scripts/build \
--docker-images \
--docker-namespace="kibana-ci" \
--docker-tag="git-$GIT_ABBREV_COMMIT" \
--skip-docker-ubuntu \
--skip-docker-ubi \
--skip-docker-cloud \
--skip-docker-contexts
echo "--- Tag images"
docker rmi "$KIBANA_IMAGE"
docker load < "target/kibana-$BASE_VERSION-docker-image.tar.gz"
docker load < "target/kibana-serverless-$BASE_VERSION-docker-image.tar.gz"
docker tag "$KIBANA_IMAGE" "$KIBANA_IMAGE-amd64"
docker rmi "$KIBANA_IMAGE"
docker load < "target/kibana-$BASE_VERSION-docker-image-aarch64.tar.gz"
docker load < "target/kibana-serverless-$BASE_VERSION-docker-image-aarch64.tar.gz"
docker tag "$KIBANA_IMAGE" "$KIBANA_IMAGE-arm64"
echo "--- Push images"

View file

@ -42,6 +42,7 @@ else
--docker-push \
--skip-docker-ubi \
--skip-docker-ubuntu \
--skip-docker-serverless \
--skip-docker-contexts
fi

View file

@ -9,7 +9,7 @@ source "$(dirname "${0}")/config.sh"
export KIBANA_IMAGE="gcr.io/elastic-kibana-184716/demo/kibana:$DEPLOYMENT_NAME-$(git rev-parse HEAD)"
echo '--- Build Kibana'
node scripts/build --debug --docker-images --example-plugins --skip-docker-ubi --skip-docker-cloud --skip-docker-contexts
node scripts/build --debug --docker-images --example-plugins --skip-docker-ubi --skip-docker-cloud --skip-docker-serverless --skip-docker-contexts
echo '--- Build Docker image with example plugins'
cd target/example_plugins

View file

@ -4,7 +4,7 @@ set -euo pipefail
.buildkite/scripts/bootstrap.sh
node scripts/build --all-platforms --debug --skip-docker-cloud --skip-docker-ubi --skip-docker-contexts
node scripts/build --all-platforms --debug --skip-docker-cloud --skip-docker-serverless --skip-docker-ubi --skip-docker-contexts
DOCKER_FILE="kibana-$KIBANA_PKG_VERSION-SNAPSHOT-docker-image.tar.gz"

View file

@ -32,6 +32,7 @@ it('build default and oss dist for current platform, without packages, by defaul
"createDebPackage": false,
"createDockerCloud": false,
"createDockerContexts": true,
"createDockerServerless": false,
"createDockerUBI": false,
"createDockerUbuntu": false,
"createGenericFolders": true,
@ -69,6 +70,7 @@ it('builds packages if --all-platforms is passed', () => {
"createDebPackage": true,
"createDockerCloud": true,
"createDockerContexts": true,
"createDockerServerless": true,
"createDockerUBI": true,
"createDockerUbuntu": true,
"createGenericFolders": true,
@ -106,6 +108,7 @@ it('limits packages if --rpm passed with --all-platforms', () => {
"createDebPackage": false,
"createDockerCloud": false,
"createDockerContexts": true,
"createDockerServerless": false,
"createDockerUBI": false,
"createDockerUbuntu": false,
"createGenericFolders": true,
@ -143,6 +146,7 @@ it('limits packages if --deb passed with --all-platforms', () => {
"createDebPackage": true,
"createDockerCloud": false,
"createDockerContexts": true,
"createDockerServerless": false,
"createDockerUBI": false,
"createDockerUbuntu": false,
"createGenericFolders": true,
@ -181,6 +185,7 @@ it('limits packages if --docker passed with --all-platforms', () => {
"createDebPackage": false,
"createDockerCloud": true,
"createDockerContexts": true,
"createDockerServerless": true,
"createDockerUBI": true,
"createDockerUbuntu": true,
"createGenericFolders": true,
@ -226,6 +231,7 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
"createDebPackage": false,
"createDockerCloud": true,
"createDockerContexts": true,
"createDockerServerless": true,
"createDockerUBI": false,
"createDockerUbuntu": true,
"createGenericFolders": true,
@ -264,6 +270,7 @@ it('limits packages if --all-platforms passed with --skip-docker-ubuntu', () =>
"createDebPackage": true,
"createDockerCloud": true,
"createDockerContexts": true,
"createDockerServerless": true,
"createDockerUBI": true,
"createDockerUbuntu": false,
"createGenericFolders": true,

View file

@ -31,6 +31,7 @@ export function readCliArgs(argv: string[]) {
'skip-docker-ubi',
'skip-docker-ubuntu',
'skip-docker-cloud',
'skip-docker-serverless',
'release',
'skip-node-download',
'skip-cloud-dependencies-download',
@ -136,6 +137,8 @@ export function readCliArgs(argv: string[]) {
createDockerUbuntu:
isOsPackageDesired('docker-images') && !Boolean(flags['skip-docker-ubuntu']),
createDockerCloud: isOsPackageDesired('docker-images') && !Boolean(flags['skip-docker-cloud']),
createDockerServerless:
isOsPackageDesired('docker-images') && !Boolean(flags['skip-docker-serverless']),
createDockerUBI: isOsPackageDesired('docker-images') && !Boolean(flags['skip-docker-ubi']),
createDockerContexts: !Boolean(flags['skip-docker-contexts']),
targetAllPlatforms: Boolean(flags['all-platforms']),

View file

@ -31,6 +31,7 @@ export interface BuildOptions {
createDockerUBI: boolean;
createDockerUbuntu: boolean;
createDockerCloud: boolean;
createDockerServerless: boolean;
createDockerContexts: boolean;
versionQualifier: string | undefined;
targetAllPlatforms: boolean;
@ -152,6 +153,11 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
await run(Tasks.CreateDockerCloud);
}
if (options.createDockerServerless) {
// control w/ --docker-images and --skip-docker-serverless
await run(Tasks.CreateDockerServerless);
}
if (options.createDockerContexts) {
// control w/ --skip-docker-contexts
await run(Tasks.CreateDockerContexts);

View file

@ -80,6 +80,29 @@ export const CreateDockerUbuntu: Task = {
},
};
export const CreateDockerServerless: Task = {
description: 'Creating Docker Ubuntu image',
async run(config, log, build) {
await runDockerGenerator(config, log, build, {
architecture: 'x64',
baseImage: 'ubuntu',
context: false,
serverless: true,
image: true,
dockerBuildDate,
});
await runDockerGenerator(config, log, build, {
architecture: 'aarch64',
baseImage: 'ubuntu',
context: false,
serverless: true,
image: true,
dockerBuildDate,
});
},
};
export const CreateDockerUBI: Task = {
description: 'Creating Docker UBI image',
@ -152,5 +175,11 @@ export const CreateDockerContexts: Task = {
context: true,
image: false,
});
await runDockerGenerator(config, log, build, {
baseImage: 'ubuntu',
serverless: true,
context: true,
image: false,
});
},
};

View file

@ -34,6 +34,7 @@ export async function runDockerGenerator(
image: boolean;
ironbank?: boolean;
cloud?: boolean;
serverless?: boolean;
dockerBuildDate?: string;
}
) {
@ -47,13 +48,14 @@ export async function runDockerGenerator(
if (flags.baseImage === 'ubi9') imageFlavor += `-ubi9`;
if (flags.ironbank) imageFlavor += '-ironbank';
if (flags.cloud) imageFlavor += '-cloud';
if (flags.serverless) imageFlavor += '-serverless';
// General docker var config
const license = 'Elastic License';
const configuredNamespace = config.getDockerNamespace();
const imageNamespace = configuredNamespace
? configuredNamespace
: flags.cloud
: flags.cloud || flags.serverless
? 'kibana-ci'
: 'kibana';
const imageTag = `docker.elastic.co/${imageNamespace}/kibana`;
@ -104,6 +106,7 @@ export async function runDockerGenerator(
dockerBuildDate,
baseImage: flags.baseImage,
cloud: flags.cloud,
serverless: flags.serverless,
metricbeatTarball,
filebeatTarball,
ironbank: flags.ironbank,
@ -131,6 +134,14 @@ export async function runDockerGenerator(
await write(resolve(dockerBuildDir, dockerTemplate.name), dockerTemplate.generator(scope));
}
// Copy serverless-only configuration files
if (flags.serverless) {
await mkdirp(resolve(dockerBuildDir, 'config'));
await copyAll(config.resolveFromRepo('config'), resolve(dockerBuildDir, 'config'), {
select: ['serverless*.yml'],
});
}
// Copy all the needed resources into kibana-docker folder
// in order to build the docker image accordingly the dockerfile defined
// under templates/kibana_yml.template/js

View file

@ -27,6 +27,7 @@ export interface TemplateContext {
baseImage: 'none' | 'ubi8' | 'ubi9' | 'ubuntu';
baseImageName: string;
cloud?: boolean;
serverless?: boolean;
metricbeatTarball?: string;
filebeatTarball?: string;
ironbank?: boolean;

View file

@ -120,6 +120,12 @@ ENV PATH=/usr/share/kibana/bin:$PATH
# Set some Kibana configuration defaults.
COPY --chown=1000:0 config/kibana.yml /usr/share/kibana/config/kibana.yml
{{#serverless}}
COPY --chown=1000:0 config/serverless.yml /usr/share/kibana/config/serverless.yml
COPY --chown=1000:0 config/serverless.es.yml /usr/share/kibana/config/serverless.es.yml
COPY --chown=1000:0 config/serverless.oblt.yml /usr/share/kibana/config/serverless.oblt.yml
COPY --chown=1000:0 config/serverless.security.yml /usr/share/kibana/config/serverless.security.yml
{{/serverless}}
# Add the launcher/wrapper script. It knows how to interpret environment
# variables and translate them to Kibana CLI options.