Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kots]: configure werft build command #8867

Merged
merged 3 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .werft/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { deployToPreviewEnvironment } from './jobs/build/deploy-to-preview-envir
import { triggerIntegrationTests } from './jobs/build/trigger-integration-tests';
import { jobConfig } from './jobs/build/job-config';
import { typecheckWerftJobs } from './jobs/build/typecheck-werft-jobs';
import { publishKotsUnstable } from './jobs/build/publish-kots-unstable'

// Will be set once tracing has been initialized
let werft: Werft
Expand Down Expand Up @@ -59,4 +60,5 @@ async function run(context: any) {

await deployToPreviewEnvironment(werft, config)
await triggerIntegrationTests(werft, config, context.Owner)
await publishKotsUnstable(werft, config)
}
10 changes: 10 additions & 0 deletions .werft/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ pod:
key: segmentIOToken
- name: JAVA_HOME
value: /home/gitpod/.sdkman/candidates/java/current
- name: REPLICATED_APP
valueFrom:
secretKeyRef:
name: replicated
key: app
- name: REPLICATED_API_TOKEN
valueFrom:
secretKeyRef:
name: replicated
key: token
command:
- bash
- -c
Expand Down
2 changes: 1 addition & 1 deletion .werft/jobs/build/build-and-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function buildAndPublish(werft: Werft, jobConfig: JobConfig) {
if (withContrib || publishRelease) {
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${dontTest ? '--dont-test' : ''} -Dversion=${version} -DimageRepoBase=${imageRepo} contrib:all`);
}
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${dontTest ? '--dont-test' : ''} ${retag} --coverage-output-path=${coverageOutput} -Dversion=${version} -DremoveSources=false -DimageRepoBase=${imageRepo} -DlocalAppVersion=${localAppVersion} -DSEGMENT_IO_TOKEN=${process.env.SEGMENT_IO_TOKEN} -DnpmPublishTrigger=${publishToNpm ? Date.now() : 'false'} -DjbMarketplacePublishTrigger=${publishToJBMarketplace ? Date.now() : 'false'}`);
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${dontTest ? '--dont-test' : ''} ${retag} --coverage-output-path=${coverageOutput} -Dversion=${version} -DremoveSources=false -DimageRepoBase=${imageRepo} -DlocalAppVersion=${localAppVersion} -DSEGMENT_IO_TOKEN=${process.env.SEGMENT_IO_TOKEN} -DREPLICATED_API_TOKEN=${process.env.REPLICATED_API_TOKEN} -DREPLICATED_APP=${process.env.REPLICATED_APP} -DnpmPublishTrigger=${publishToNpm ? Date.now() : 'false'} -DjbMarketplacePublishTrigger=${publishToJBMarketplace ? Date.now() : 'false'}`);
if (publishRelease) {
try {
werft.phase("publish", "checking version semver compliance...");
Expand Down
39 changes: 39 additions & 0 deletions .werft/jobs/build/publish-kots-unstable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { exec } from '../../util/shell';
import { Werft } from "../../util/werft";
import { JobConfig } from "./job-config";

const phases = {
PUBLISH_KOTS_UNSTABLE: 'publish kots unstable',
};

const REPLICATED_SECRET = 'replicated';
const REPLICATED_CHANNEL = 'Unstable';
const REPLICATED_YAML_DIR = './install/kots/manifests';
const INSTALLER_JOB_IMAGE = 'spec.template.spec.containers[0].image';

export async function publishKotsUnstable(werft: Werft, config: JobConfig) {
if (config.mainBuild) {
werft.phase(phases.PUBLISH_KOTS_UNSTABLE, 'Publish unstable release to KOTS');

const imageAndTag = exec(`yq r ${REPLICATED_YAML_DIR}/gitpod-installer-job.yaml ${INSTALLER_JOB_IMAGE}`);
const [image] = imageAndTag.split(':');

// Set the tag to the current version
exec(`yq w -i ${REPLICATED_YAML_DIR}/gitpod-installer-job.yaml ${INSTALLER_JOB_IMAGE} ${image}:${config.version}`);

const app = exec(`kubectl get secret ${REPLICATED_SECRET} --namespace werft -o jsonpath='{.data.app}' | base64 -d`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be easier to just use process.env.REPLICATED_API_TOKEN and process.env.REPLICATED_APP instead?

const token = exec(`kubectl get secret ${REPLICATED_SECRET} --namespace werft -o jsonpath='{.data.token}' | base64 -d`);

exec(`replicated release create \
--lint \
--ensure-channel \
--app ${app} \
--token ${token} \
--yaml-dir ${REPLICATED_YAML_DIR} \
--version ${config.version} \
--release-notes "# ${config.version}\n\nSee [Werft job](https://werft.gitpod-dev.com/job/gitpod-build-${config.version}/logs) for notes" \
--promote ${REPLICATED_CHANNEL}`);

werft.done(phases.PUBLISH_KOTS_UNSTABLE);
}
}
1 change: 1 addition & 0 deletions components/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ packages:
- :publish-api
- dev:all-app
- install/installer:docker
- install/kots:lint
- components/gitpod-protocol:all
- operations/observability/mixins:lint
- name: docker-versions
Expand Down
14 changes: 14 additions & 0 deletions install/kots/BUILD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

packages:
- name: lint
type: generic
srcs:
- "**/*"
argdeps:
- REPLICATED_API_TOKEN
- REPLICATED_APP
config:
commands:
- ["make", "lint"]
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-certificate-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-cloudsql-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-config-patch.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-database-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-installation.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

# This exists as debug information for the support bundle
apiVersion: v1
kind: ConfigMap
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-installer-job.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

# The installer job is where the magic happens. It generates
# the config, installs Gitpod and then deletes itself when
# it's finished
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-license.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-registry-s3-backend.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-registry-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-storage-azure-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-storage-gcp-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/gitpod-storage-s3-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/kots-app.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: kots.io/v1beta1
kind: Application
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/kots-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: kots.io/v1beta1
kind: Config
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/kots-preflight.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
Expand Down
3 changes: 3 additions & 0 deletions install/kots/manifests/kots-support-bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.

apiVersion: troubleshoot.replicated.com/v1beta1
kind: SupportBundle
metadata:
Expand Down