用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tools-only/X-Skills --skill nodejs-api命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Index of Build Systems Skills
Coordination patterns for distributed dataflow systems including barriers, epochs, and distributed snapshots
Windowing, sessionization, time-series aggregation, and late data handling for streaming systems
基于 SOC 职业分类
正在显示 SKILL.md
| description | Generate Helm chart for Kubernetes application |
| shortcut | kh |
| category | devops |
| difficulty | advanced |
| estimated_time | 3 minutes |
Creates production-ready Helm charts for Kubernetes applications with parameterized templates, values files, and best practices.
/k8s-manifest-generate)kubectl run)You are a Helm expert. When user runs /k8s-helm-chart or /kh:
Detect application:
Generate chart structure:
mychart/
├── Chart.yaml # Chart metadata
├── values.yaml # Default values
├── values-dev.yaml # Dev overrides
├── values-prod.yaml # Production overrides
├── templates/
│ ├── deployment.yaml # Parameterized deployment
│ ├── service.yaml # Parameterized service
│ ├── ingress.yaml # Conditional ingress
│ ├── configmap.yaml # Configuration
│ ├── secret.yaml # Secrets (template only)
│ ├── hpa.yaml # Auto-scaling (conditional)
│ └── _helpers.tpl # Template helpers
└── README.md # Usage documentation
Parameterize templates:
{{ .Values.* }})Provide values files:
Include deployment guide:
# Complete chart directory structure
# Ready to use with helm install/upgrade
## Installation
### Install chart:
```bash
helm install myapp ./mychart -f values-prod.yaml
helm upgrade myapp ./mychart -f values-prod.yaml
helm rollback myapp <revision>
## Example
**User:** `/kh` (for Node.js API)
**Questions:**
- App name? → `nodejs-api`
- Chart version? → `1.0.0`
- Default image? → `myregistry/nodejs-api:latest`
- Configurable options? → Replicas, resources, ingress, auto-scaling
**Output:**
```yaml
# Chart.yaml
apiVersion: v2
name: nodejs-api
description: Production-ready Node.js API Helm chart
type: application
version: 1.0.0
appVersion: "1.0.0"
keywords:
- nodejs
- api
- microservice
maintainers:
- name: Your Name
email: [email protected]
# values.yaml
# Default values for nodejs-api chart
# Docker image configuration
image:
repository: myregistry/nodejs-api
pullPolicy: IfNotPresent
tag: "latest" # Override this in production!
# Number of replicas
replicaCount: 3
# Resource limits and requests
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 500m
memory: 1Gi
# Horizontal Pod Autoscaler (HPA)
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80
# Service configuration
service:
type: ClusterIP
port: 80
targetPort: 3000
# Ingress configuration
ingress:
enabled: true
className: nginx
annotations:
{}
{}
[]
{}
# values-dev.yaml
# Development environment overrides
replicaCount: 1
autoscaling:
enabled: false
image:
tag: "dev"
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 250m
memory: 512Mi
ingress:
enabled: true
hosts:
- host: api-dev.example.com
paths:
- path: /
pathType: Prefix
config:
NODE_ENV: "development"
LOG_LEVEL: "debug"
# values-prod.yaml
# Production environment overrides
replicaCount: 5
image:
tag: "1.0.0" # Specific version, not 'latest'
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 20
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: 1000m
memory: 2Gi
ingress:
enabled: true
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/rate-limit: "100"
hosts:
- host: api.example.com
paths:
- path: /
pathType: Prefix
config:
NODE_ENV: "production"
LOG_LEVEL: "info"
# Pod disruption budget for high availability
podDisruptionBudget:
enabled: true
minAvailable:
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "nodejs-api.fullname" . }}
labels:
{{- include "nodejs-api.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "nodejs-api.selectorLabels" . | nindent 6 }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
# templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: {{ include "nodejs-api.fullname" . }}
labels:
{{- include "nodejs-api.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "nodejs-api.selectorLabels" . | nindent 4 }}
# templates/ingress.yaml
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "nodejs-api.fullname" . }}
labels:
{{- include "nodejs-api.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
# templates/hpa.yaml
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "nodejs-api.fullname" . }}
labels:
{{- include "nodejs-api.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "nodejs-api.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{ }}
{{ }}
{{/* templates/_helpers.tpl */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "nodejs-api.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
*/}}
{{- define "nodejs-api.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nodejs-api.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "nodejs-api.labels" -}}
helm.sh/chart: {{ include "nodejs-api.chart" . }}
{{ include "nodejs-api.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "nodejs-api.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nodejs-api.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Deployment Guide:
# Helm Chart Usage
## Installation
### Development:
```bash
helm install nodejs-api ./nodejs-api -f values-dev.yaml
# Set secrets via command line (more secure)
helm install nodejs-api ./nodejs-api \
-f values-prod.yaml \
--set secrets.DATABASE_URL="postgresql://..." \
--set secrets.JWT_SECRET="..." \
--set secrets.API_KEY="..."
helm upgrade nodejs-api ./nodejs-api -f values-prod.yaml
# List revisions
helm history nodejs-api
# Rollback to previous
helm rollback nodejs-api
# Rollback to specific revision
helm rollback nodejs-api 3
helm list
helm status nodejs-api
kubectl get pods -l app.kubernetes.io/name=nodejs-api
helm uninstall nodejs-api
Use values files for environments (values-{env}.yaml) Set secrets via --set (don't commit them) Pin image tags in production (not 'latest') Test with: helm template nodejs-api ./nodejs-api -f values-prod.yaml Validate with: helm lint ./nodejs-api