ci: update hello-world app files
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
COPY index.html /usr/share/nginx/html/index.html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
||||||
Vendored
+152
@@ -0,0 +1,152 @@
|
|||||||
|
// Build -> registry -> deploy, with nothing written back into this repository: Jenkins builds the image with BuildKit
|
||||||
|
// (no privileged docker-in-docker) and pushes it to Harbor as :<commit> and :latest, using the project's push-only robot
|
||||||
|
// account. Argo CD Image Updater (ImageUpdater hello-world in namespace argocd) sees the new :<commit> tag in Harbor and
|
||||||
|
// points the Argo CD application at it. No commit back means no webhook loop, so no [skip ci] commits and no extra builds.
|
||||||
|
// AI-1044: the build pod runs only buildctl; BuildKit itself is the rootless buildkitd in namespace buildkit
|
||||||
|
// (k3s2-install-jenkins templates/buildkitd.yml.j2), which buildctl reaches over TCP with mutual TLS. So the pod needs no
|
||||||
|
// Unconfined profile and meets the restricted Pod Security level that namespace jenkins-agents enforces.
|
||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
kubernetes {
|
||||||
|
label 'buildkit-agent'
|
||||||
|
// AI-979: the agent's jnlp container (its remoting JVM runs the pipeline steps) comes from the chart's
|
||||||
|
// default pod template (k3s2-install-jenkins agent.*): the pinned inbound-agent image with the fixed JDK
|
||||||
|
// and JENKINS_JAVA_OPTS with the Base64 intrinsic flag. A declarative template inherits nothing by itself,
|
||||||
|
// and without it the plugin adds its own built-in jnlp container, unpinned and without the flag.
|
||||||
|
// AI-1044: the plugin gives that jnlp container the restricted securityContext (the cloud's
|
||||||
|
// restrictedPssSecurityContext); the pod's own securityContext below makes it run as uid 1000, which the
|
||||||
|
// image's user name (jenkins) does not tell the kubelet.
|
||||||
|
inheritFrom 'default'
|
||||||
|
yaml """
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
spec:
|
||||||
|
# AI-1035: the agents' account in namespace jenkins-agents, no API rights and no token; the build needs no API.
|
||||||
|
serviceAccountName: jenkins-agent
|
||||||
|
securityContext:
|
||||||
|
runAsNonRoot: true
|
||||||
|
runAsUser: 1000
|
||||||
|
runAsGroup: 1000
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
|
containers:
|
||||||
|
- name: buildctl
|
||||||
|
image: moby/buildkit:v0.33.1-rootless
|
||||||
|
command: ['sleep']
|
||||||
|
args: ['99d']
|
||||||
|
env:
|
||||||
|
# buildctl is Go: SSL_CERT_DIR adds the internal CA (/certs) to its trust store, beside the image's own bundle.
|
||||||
|
- name: SSL_CERT_DIR
|
||||||
|
value: /etc/ssl/certs:/certs
|
||||||
|
# buildctl fetches the registries' tokens itself (Docker Hub's for the base image through the gateway's squid,
|
||||||
|
# Harbor's directly); the daemon is buildkitd.buildkit.svc, in NO_PROXY's .svc.
|
||||||
|
- name: HTTP_PROXY
|
||||||
|
value: http://10.0.10.5:3128
|
||||||
|
- name: HTTPS_PROXY
|
||||||
|
value: http://10.0.10.5:3128
|
||||||
|
- name: NO_PROXY
|
||||||
|
value: localhost,127.0.0.1,10.0.0.0/8,.cluster.local,.svc,.smoke-k3s2-api-20261204.app.ariki.ai
|
||||||
|
- name: http_proxy
|
||||||
|
value: http://10.0.10.5:3128
|
||||||
|
- name: https_proxy
|
||||||
|
value: http://10.0.10.5:3128
|
||||||
|
- name: no_proxy
|
||||||
|
value: localhost,127.0.0.1,10.0.0.0/8,.cluster.local,.svc,.smoke-k3s2-api-20261204.app.ariki.ai
|
||||||
|
# AI-1044: the restricted level's container fields; the pod's securityContext above sets the user and seccomp.
|
||||||
|
securityContext:
|
||||||
|
runAsNonRoot: true
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
capabilities:
|
||||||
|
drop:
|
||||||
|
- ALL
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
|
volumeMounts:
|
||||||
|
# the client certificate buildkitd accepts (k3s2-install-jenkins' Certificate buildkit-client, Secret
|
||||||
|
# buildkit-client-tls) and the internal CA that signed it and the daemon's certificate (ca.crt)
|
||||||
|
- name: buildkit-client
|
||||||
|
mountPath: /tls
|
||||||
|
readOnly: true
|
||||||
|
- name: internal-root-ca
|
||||||
|
mountPath: /certs
|
||||||
|
readOnly: true
|
||||||
|
# Harbor push credentials: the push-only robot (ExternalSecret hello-world-harbor-push). buildctl
|
||||||
|
# hands them to the daemon through its session; the daemon keeps no registry credential.
|
||||||
|
- name: harbor-push
|
||||||
|
mountPath: /home/user/.docker
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: buildkit-client
|
||||||
|
secret:
|
||||||
|
secretName: buildkit-client-tls
|
||||||
|
- name: internal-root-ca
|
||||||
|
secret:
|
||||||
|
secretName: internal-root-ca
|
||||||
|
- name: harbor-push
|
||||||
|
secret:
|
||||||
|
secretName: hello-world-harbor-push
|
||||||
|
items:
|
||||||
|
- key: .dockerconfigjson
|
||||||
|
path: config.json
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
triggers {
|
||||||
|
GenericTrigger(
|
||||||
|
genericVariables: [
|
||||||
|
[key: 'ref', value: '$.ref'],
|
||||||
|
[key: 'commit_message', value: '$.head_commit.message']
|
||||||
|
],
|
||||||
|
token: 'gitea-webhook'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
HARBOR_HOST = "harbor.smoke-k3s2-api-20261204.app.ariki.ai"
|
||||||
|
HARBOR_PROJECT = "smoke-k3s2-api-20261204"
|
||||||
|
IMAGE_NAME = "${HARBOR_HOST}/${HARBOR_PROJECT}/hello-world"
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Build and push image') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// The commit, not BUILD_NUMBER: unique even if the job is recreated, and it names the source
|
||||||
|
// the image was built from. The ImageUpdater only accepts tags of this shape.
|
||||||
|
env.IMAGE_TAG = env.GIT_COMMIT.take(12)
|
||||||
|
currentBuild.description = env.IMAGE_TAG
|
||||||
|
}
|
||||||
|
container('buildctl') {
|
||||||
|
// AI-1044: buildkitd in namespace buildkit builds and pushes; buildctl presents the client certificate
|
||||||
|
// and checks the daemon's against the internal CA. buildkitd.toml there gives the daemon the internal
|
||||||
|
// CA for Harbor (blob push); the registry token is fetched by buildctl itself, which needs it too
|
||||||
|
// (--registry-auth-tlscontext), or the push fails with "failed to fetch oauth token ... x509:
|
||||||
|
// certificate signed by unknown authority".
|
||||||
|
sh '''
|
||||||
|
buildctl \
|
||||||
|
--addr tcp://buildkitd.buildkit.svc:1234 \
|
||||||
|
--tlscacert /tls/ca.crt \
|
||||||
|
--tlscert /tls/tls.crt \
|
||||||
|
--tlskey /tls/tls.key \
|
||||||
|
build \
|
||||||
|
--frontend dockerfile.v0 \
|
||||||
|
--local context=. \
|
||||||
|
--local dockerfile=. \
|
||||||
|
--registry-auth-tlscontext "host=${HARBOR_HOST},ca=/certs/ca.crt" \
|
||||||
|
--output "type=image,\\"name=${IMAGE_NAME}:${IMAGE_TAG},${IMAGE_NAME}:latest\\",push=true"
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
echo "Pushed ${IMAGE_NAME}:${IMAGE_TAG}; Argo CD Image Updater deploys it to https://hello-world.smoke-k3s2-api-20261204.app.ariki.ai"
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo "Pipeline failed at: ${env.STAGE_NAME}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Hello World</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello from K3s cluster!</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: hello-world
|
||||||
|
namespace: hello-world
|
||||||
|
spec:
|
||||||
|
replicas: 2
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: hello-world
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: hello-world
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: harbor-pull-secret
|
||||||
|
containers:
|
||||||
|
- name: hello-world
|
||||||
|
image: harbor.smoke-k3s2-api-20261204.app.ariki.ai/smoke-k3s2-api-20261204/hello-world:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 50m
|
||||||
|
memory: 64Mi
|
||||||
|
limits:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 128Mi
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: 80
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# AI-889: how the demo is reached, and the file to copy for an app of your own.
|
||||||
|
# The route attaches to listener hello-world of Gateway web in envoy-gateway-system, which the platform (k3s2-3)
|
||||||
|
# creates on core and app clusters alike for hello-world.<cluster domain>. That listener admits routes only from
|
||||||
|
# namespace hello-world, so this route only works in that namespace; a copy in another namespace is not accepted.
|
||||||
|
# TLS ends at the listener with the platform's certificate, so the route carries no TLS settings and the app needs
|
||||||
|
# no Certificate of its own.
|
||||||
|
# AI-889: every field the Gateway API HTTPRoute CRD (v1.6.1) defaults is written out, at the value the API server
|
||||||
|
# gives it: parentRefs group and kind, backendRefs group, kind and weight, and the rule's match on every path. Argo CD
|
||||||
|
# compares this file with the live route on its own side, field by field, and a defaulted field left out here kept the
|
||||||
|
# app OutOfSync for ever (live gate, 2026-11-28). Keep them in a copy, or turn on Argo CD's server-side diff for it.
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: HTTPRoute
|
||||||
|
metadata:
|
||||||
|
name: hello-world
|
||||||
|
namespace: hello-world
|
||||||
|
spec:
|
||||||
|
parentRefs:
|
||||||
|
- group: gateway.networking.k8s.io
|
||||||
|
kind: Gateway
|
||||||
|
name: web
|
||||||
|
namespace: envoy-gateway-system
|
||||||
|
sectionName: hello-world
|
||||||
|
hostnames:
|
||||||
|
- hello-world.smoke-k3s2-api-20261204.app.ariki.ai
|
||||||
|
rules:
|
||||||
|
- matches:
|
||||||
|
- path:
|
||||||
|
type: PathPrefix
|
||||||
|
value: /
|
||||||
|
backendRefs:
|
||||||
|
- group: ""
|
||||||
|
kind: Service
|
||||||
|
name: hello-world
|
||||||
|
port: 80
|
||||||
|
weight: 1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
# A Kustomize application, so Argo CD Image Updater can set the image tag as an Application override
|
||||||
|
# (spec.source.kustomize.images) instead of anyone committing it into deployment.yml.
|
||||||
|
resources:
|
||||||
|
- deployment.yml
|
||||||
|
- service.yml
|
||||||
|
- httproute.yml
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: hello-world
|
||||||
|
namespace: hello-world
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: hello-world
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 80
|
||||||
Reference in New Issue
Block a user