Installation
Install as Agent Plugin
Recommended
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install gke-app-onboarding@skills-hub
Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled).
Plugin gke-app-onboarding v1.0.0 follows the Agent Plugins spec.
Install with the gh extension
gh skills-hub install gke-app-onboarding Don't have the extension? Run gh extension install samueltauil/skills-hub first.
Download and extract to your repository:
.github/skills/gke-app-onboarding/ Extract the ZIP to .github/skills/ in your repo. The folder name must match gke-app-onboarding for Copilot to auto-discover it.
Skill Files (8)
SKILL.md 5.9 KB
---
name: gke-app-onboarding
description: >-
Manages GKE application onboarding, covering containerization, deployment
manifests, and migration. Use when onboarding or deploying an application to
GKE for the first time, or containerizing an app for GKE. Don't use for
general GKE cluster administration or upgrades (use gke-basics or
gke-upgrades instead).
metadata:
version: "1.0.1"
category: Containers
---
# GKE App Onboarding
This reference provides workflows for containerizing and deploying applications
to GKE for the first time.
> **MCP Tools:** `apply_k8s_manifest`, `get_k8s_resource`,
> `get_k8s_rollout_status`, `get_k8s_logs`, `describe_k8s_resource`
## Attribution
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
MUST read [Usage Attribution](references/attribution.md). For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix `gcloud` with
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-app-onboarding)"`
and append `agent-skills/1.0 (skill:gke-app-onboarding)` to `User-Agent` headers.
## Workflow
### 1. App Assessment
Before containerizing, assess the application:
- **Language & Framework**: Identify the tech stack
- **Dependencies**: List required libraries and external services
- **Configuration**: How is the app configured? (env vars, config files,
secrets)
- **Statefulness**: Does it need persistent storage? (databases, file storage)
- **Networking**: Port mapping and protocol (HTTP, gRPC, TCP)
- **Health endpoints**: Does the app expose health check endpoints?
### 2. Containerization
Create a container image. A Dockerfile with a multi-stage build is recommended
for most apps — see the Go Dockerfile in
[`references/go-example.md`](./references/go-example.md) for a worked example.
**Best practices:**
- Use multi-stage builds to keep production images small
- Use distroless or minimal base images to reduce attack surface
- Run as non-root user
- Log to `stdout` and `stderr` for Cloud Logging collection
A complete worked Node.js example is provided in [`assets/`](./assets/):
[`Dockerfile`](./assets/Dockerfile) (non-root `node` user),
[`index.js`](./assets/index.js) (implements distinct `/healthz` and `/readyz`
endpoints), [`package.json`](./assets/package.json), and
[`deployment.yaml`](./assets/deployment.yaml) (hardened Deployment plus
ClusterIP Service, probes wired to `/healthz` and `/readyz`).
For applications where writing a Dockerfile is not preferred, you can use
[**Cloud Native Buildpacks**](https://buildpacks.io/) to automatically detect
the language and build a container image:
```bash
pack build <image> --builder gcr.io/buildpacks/builder:latest
```
### 3. Image Management
Build and store the container image:
```bash
# Configure Docker for Artifact Registry
gcloud auth configure-docker <REGION>-docker.pkg.dev --quiet
# Build and push
docker build -t <REGION>-docker.pkg.dev/<PROJECT>/<REPO>/<IMAGE>:<TAG> .
docker push <REGION>-docker.pkg.dev/<PROJECT>/<REPO>/<IMAGE>:<TAG>
```
**Vulnerability scanning**: Enable automatic scanning in Artifact Registry to
detect issues in base images and dependencies.
```bash
# Check scan results
gcloud artifacts docker images describe \
<REGION>-docker.pkg.dev/<PROJECT>/<REPO>/<IMAGE>:<TAG> \
--show-package-vulnerability \
--quiet
```
### 4. Manifest Generation
Generate Kubernetes manifests for the application. A baseline Deployment +
ClusterIP Service manifest (probes, resource requests/limits, 2 replicas) is in
[`references/go-example.md`](./references/go-example.md).
**Checklist for manifests:**
- Resource requests and limits set
- Liveness and readiness probes configured
- At least 2 replicas for production
- Service type appropriate (ClusterIP for internal, use Gateway API for
external)
See [`assets/deployment.yaml`](./assets/deployment.yaml) for a hardened worked
example. A production-hardened pod spec must include ALL of: `runAsNonRoot:
true`, `readOnlyRootFilesystem: true`, `allowPrivilegeEscalation: false`,
`capabilities.drop: ["ALL"]`, `seccompProfile: {type: RuntimeDefault}`,
`automountServiceAccountToken: false` (unless the pod needs the token — then say
why), resource requests, digest-pinned image, and a ClusterIP Service.
That checklist is the baseline for any pod spec produced here. For manifest work
beyond it — Gateway API routes, GCS FUSE and secret volume mounting, `subPath`
overlays, Spot VM targeting, or AI/inference serving specs — see
`gke-manifest-generation`.
### 5. Deploy
```
# MCP (preferred)
apply_k8s_manifest(parent="projects/<PROJECT>/locations/<REGION>/clusters/<CLUSTER>", yamlManifest="<manifest>")
# Verify
get_k8s_rollout_status(parent="...", resourceType="deployment", name="my-app")
get_k8s_resource(parent="...", resourceType="pod", labelSelector="app=my-app")
```
**kubectl fallback:**
```bash
kubectl apply -f manifests/
kubectl rollout status deployment/my-app
kubectl get pods -l app=my-app
```
## Golden Path Onboarding Checklist
For every production application onboarding to GKE:
1. **Container Security**: Non-root user (`runAsNonRoot: true`), lockfile
install, minimal/distroless base image.
2. **Resource Requests**: Explicit CPU and memory requests (mandatory for GKE
Autopilot).
3. **Health Probes**: Both liveness (`livenessProbe`) and readiness
(`readinessProbe`) probes configured.
4. **Reliability & Availability**: At least 2 replicas and a
`PodDisruptionBudget` (`minAvailable: 1` or `2`).
5. **IAM & Workload Identity**: Workload Identity
(`iam.gke.io/gcp-service-account`) instead of static service account keys.
## Next Steps
Once the application is running on GKE:
- Configure autoscaling — see the `gke-workload-scaling` skill
- Set up observability — see the `gke-observability` skill
- Harden security — see the `gke-workload-security` skill
- Configure reliability (PDBs, topology spread) — see the `gke-reliability`
skill
assets/
Dockerfile 0.5 KB
# Use official lightweight Node.js image
FROM node:22-slim
# Set working directory
WORKDIR /app
# Copy package files and install dependencies using lockfile
COPY package*.json ./
RUN npm ci --omit=dev
# Copy the application code
COPY index.js .
# Expose the application port
EXPOSE 8080
# Run the application as a non-root user for security.
# The official images define `node` as uid/gid 1000 — keep this in sync with
# runAsUser/runAsGroup in deployment.yaml.
USER node
# Start the application
CMD [ "node", "index.js" ]
deployment.yaml 1.9 KB
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-app-deployment
namespace: my-app # Replace with your namespace
labels:
app: node-app
spec:
replicas: 3
selector:
matchLabels:
app: node-app
template:
metadata:
labels:
app: node-app
spec:
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
# Matches the `node` user (uid/gid 1000) set via USER in the Dockerfile
runAsUser: 1000
runAsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: node-app
# Replace with your actual Artifact Registry image path and real digest,
# e.g., us-docker.pkg.dev/<PROJECT_ID>/<REPO>/node-app@sha256:<DIGEST>
image: us-docker.pkg.dev/my-project/my-repo/node-app@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
ports:
- containerPort: 8080
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "200m"
memory: "256Mi"
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
readinessProbe:
httpGet:
path: /readyz
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: node-app-service
namespace: my-app # Replace with your namespace
spec:
selector:
app: node-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
# ClusterIP for internal access; for external exposure use the Gateway API —
# see the gke-service-networking skill
type: ClusterIP
index.js 0.8 KB
const http = require('http');
const port = process.env.PORT || 8080;
// Flipped once the server is listening; gate readiness on any startup work.
let ready = false;
const server = http.createServer((req, res) => {
if (req.url === '/healthz') {
// Liveness: the process is up and able to serve requests
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('OK');
} else if (req.url === '/readyz') {
// Readiness: only accept traffic once startup is complete
res.statusCode = ready ? 200 : 503;
res.setHeader('Content-Type', 'text/plain');
res.end(ready ? 'READY' : 'NOT READY');
} else {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello, World!\n');
}
});
server.listen(port, () => {
ready = true;
console.log(`Server running on port ${port}`);
});
package-lock.json 0.2 KB
{
"name": "simple-node-app",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "simple-node-app",
"version": "1.0.0"
}
}
}
package.json 0.1 KB
{
"name": "simple-node-app",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
}
}
references/
attribution.md 1.8 KB
# Usage Attribution
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command with
this skill, follow these usage attribution instructions. Tag every command you
execute directly in the terminal so usage can be attributed. The tag identifies
only the skill and its version; it carries no user data.
- **`gcloud` CLI Commands**: Prefix every `gcloud` invocation, whatever the
subcommand, with the metrics environment variable. Set it inline on each
command because shell state may not persist between commands:
```bash
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-app-onboarding)" \
gcloud <command> [flags]
```
Do not use `gcloud config set` for this: it would persist beyond the current
task and mislabel unrelated usage.
- **Direct HTTP, REST, and MCP Requests**: On direct HTTP calls to Google
Cloud APIs (for example with `curl`) or HTTP requests to a remote MCP
server, include `agent-skills/1.0 (skill:gke-app-onboarding)` in the `User-Agent`
header. If a `User-Agent` header is already specified, append this string to
the end of it rather than overwriting existing `User-Agent` data — the
collection pipeline parses the `agent-skills/<version>` and `skill:<name>`
tokens, so any rewording breaks attribution:
```
User-Agent: <existing_user_agent> agent-skills/1.0 (skill:gke-app-onboarding)
```
- **Constraint for Generated Code**: The tracking prefix is strictly for
commands you execute directly in the terminal. Do NOT include this tracking
prefix in generated scripts, Terraform templates, or code provided to the
user for their own repositories.
- **User Opt-Out**: If the user asks to disable or remove tracking or
attribution tags, omit the `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` variable
and custom `User-Agent` suffix from all commands.
go-example.md 2.0 KB
# Go Containerization & Manifest Example
<!-- disableFinding(LINK_RELATIVE_G3DOC) -->
Worked Go example for the [gke-app-onboarding](../SKILL.md) workflow: a
multi-stage distroless Dockerfile and a baseline Deployment + Service manifest.
For a complete hardened Node.js example (app code, Dockerfile, and manifest),
see [`../assets/`](../assets/).
## Multi-stage Go Dockerfile
Multi-stage build producing a small, non-root distroless image:
```dockerfile
# Multi-stage build for smaller, more secure images
FROM golang:1.22 AS builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 go build -o server .
FROM gcr.io/distroless/static:nonroot
COPY --from=builder /app/server /server
USER nonroot:nonroot
EXPOSE 8080
ENTRYPOINT ["/server"]
```
## Baseline Deployment + Service manifest
Starting-point manifest with resource requests/limits, liveness/readiness
probes, 2 replicas, and a ClusterIP Service. For a hardened variant (non-root
securityContext, read-only root filesystem, digest-pinned image), see
[`../assets/deployment.yaml`](../assets/deployment.yaml).
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
namespace: my-app # Replace with your namespace
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: <REGION>-docker.pkg.dev/<PROJECT>/<REPO>/<IMAGE>:<TAG>
ports:
- containerPort: 8080
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
readinessProbe:
httpGet:
path: /readyz
port: 8080
initialDelaySeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: my-app
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 8080
type: ClusterIP
```
License (Apache-2.0)
Apache-2.0
Source: google/skills
View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/google/skills/blob/main/LICENSE