Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:19:47 +08:00
commit ff6c9a6df4
14 changed files with 582 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
# Assets
Bundled resources for kubernetes-deployment-creator skill
- [ ] deployment_template.yaml: A template for a basic Kubernetes deployment manifest.
- [ ] service_template.yaml: A template for a basic Kubernetes service manifest.
- [ ] ingress_template.yaml: A template for a basic Kubernetes ingress manifest.
- [ ] hpa_template.yaml: A template for a basic Kubernetes Horizontal Pod Autoscaler manifest.
- [ ] configmap_template.yaml: A template for a basic Kubernetes ConfigMap manifest.
- [ ] secret_template.yaml: A template for a basic Kubernetes Secret manifest.

View File

@@ -0,0 +1,33 @@
# Kubernetes ConfigMap Template
# This ConfigMap stores configuration data that can be consumed by pods.
apiVersion: v1
kind: ConfigMap
metadata:
name: REPLACE_ME-config # Replace with your ConfigMap name (e.g., myapp-config)
namespace: default # Optional: Specify the namespace (e.g., production, staging)
labels:
app: REPLACE_ME # Replace with your application name (e.g., myapp)
tier: backend # Optional: Tier or component of the application
data:
# Define your configuration key-value pairs here.
# These values can be accessed by your application running in the pod.
# Example: Application settings
APP_ENVIRONMENT: "production" # or "staging", "development"
LOG_LEVEL: "INFO" # or "DEBUG", "WARNING", "ERROR"
# Example: Database connection details
DATABASE_HOST: "YOUR_VALUE_HERE" # Replace with your database hostname/IP address
DATABASE_PORT: "5432" # Replace with your database port
DATABASE_NAME: "YOUR_VALUE_HERE" # Replace with your database name
DATABASE_USER: "YOUR_VALUE_HERE" # Replace with your database username
# Example: Feature flags (boolean values as strings)
ENABLE_NEW_FEATURE: "true" # or "false"
# Example: API endpoint
API_ENDPOINT: "https://api.example.com" # Replace with your API endpoint
# Add more configuration entries as needed. Remember to quote values that might be interpreted as numbers or booleans if you want them to be strings.

View File

@@ -0,0 +1,58 @@
# deployment_template.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: REPLACE_ME-deployment
labels:
app: REPLACE_ME
spec:
replicas: 3 # Number of desired pods
selector:
matchLabels:
app: REPLACE_ME
strategy:
type: RollingUpdate # Use rolling updates for zero-downtime deployments
rollingUpdate:
maxSurge: 25% # Allow up to 25% more pods than desired during update
maxUnavailable: 25% # Ensure at least 75% of pods are available during update
template:
metadata:
labels:
app: REPLACE_ME
spec:
containers:
- name: REPLACE_ME-container
image: YOUR_VALUE_HERE # Replace with your container image
imagePullPolicy: IfNotPresent # Only pull the image if it's not present
ports:
- containerPort: 80 # The port your application listens on
name: http
protocol: TCP
resources: # Define resource requests and limits
requests:
cpu: 100m # Minimum CPU required (100 millicores)
memory: 256Mi # Minimum memory required (256 mebibytes)
limits:
cpu: 500m # Maximum CPU allowed (500 millicores)
memory: 512Mi # Maximum memory allowed (512 mebibytes)
livenessProbe: # Check if the container is running
httpGet:
path: /healthz # Replace with your health check endpoint
port: 80
initialDelaySeconds: 30 # Wait 30 seconds after container starts
periodSeconds: 10 # Check every 10 seconds
timeoutSeconds: 5 # Timeout after 5 seconds
failureThreshold: 3 # Retry 3 times before considering the container unhealthy
readinessProbe: # Check if the container is ready to serve traffic
httpGet:
path: /readyz # Replace with your readiness check endpoint
port: 80
initialDelaySeconds: 15 # Wait 15 seconds after container starts
periodSeconds: 10 # Check every 10 seconds
timeoutSeconds: 5 # Timeout after 5 seconds
failureThreshold: 3 # Retry 3 times before considering the container not ready
# Add environment variables here if needed
# env:
# - name: MY_ENV_VAR
# value: "YOUR_VALUE_HERE"

View File

@@ -0,0 +1,28 @@
# hpa_template.yaml
# Template for a Kubernetes Horizontal Pod Autoscaler (HPA)
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: REPLACE_ME-hpa # Replace with your HPA name
namespace: YOUR_VALUE_HERE # Replace with your namespace
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: REPLACE_ME # Replace with your deployment name
minReplicas: 2 # Minimum number of replicas
maxReplicas: 10 # Maximum number of replicas
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70 # Target CPU utilization percentage
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80 # Target memory utilization percentage

View File

@@ -0,0 +1,46 @@
# ingress_template.yaml
# This file defines a basic Ingress resource for Kubernetes.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: REPLACE_ME-ingress # Replace with your ingress name
namespace: REPLACE_ME-namespace # Replace with your namespace
annotations:
# Use cert-manager to automatically provision TLS certificates
cert-manager.io/cluster-issuer: letsencrypt-prod # Replace with your cert-manager issuer
# Optional: Configure rate limiting using ingress-nginx (replace with your desired limits)
# nginx.ingress.kubernetes.io/limit-rps: "10"
# nginx.ingress.kubernetes.io/limit-burst: "20"
# Optional: Configure rewrite target if needed
# nginx.ingress.kubernetes.io/rewrite-target: /$1
# Optional: Enable sticky sessions based on cookie
# nginx.ingress.kubernetes.io/affinity: "cookie"
# nginx.ingress.kubernetes.io/session-cookie-name: "ROUTEID"
# nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
spec:
# Define ingressClassName if using a specific ingress controller (e.g., nginx)
ingressClassName: nginx # Replace with your ingress class name if needed
tls:
# Configure TLS for secure communication
- hosts:
- REPLACE_ME.YOUR_DOMAIN_HERE # Replace with your domain name
secretName: REPLACE_ME-tls # Replace with the name of your TLS secret
rules:
# Define routing rules for incoming traffic
- host: REPLACE_ME.YOUR_DOMAIN_HERE # Replace with your domain name
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: REPLACE_ME-service # Replace with your service name
port:
number: 80 # Replace with your service port

View File

@@ -0,0 +1,41 @@
# This YAML file defines a Kubernetes Secret.
# Secrets are used to store sensitive information, such as passwords, API keys, and tokens.
# It's crucial to handle Secrets securely to protect your application.
apiVersion: v1
kind: Secret
metadata:
name: REPLACE_ME-secret # Replace with a descriptive name for your secret
namespace: default # Consider using a specific namespace for your application
labels:
app: REPLACE_ME-app # Replace with your application name
tier: backend # Optional: Add a tier label if applicable
annotations:
# Optional: Add annotations for documentation or automation
description: "Secret for REPLACE_ME application"
type: Opaque # Use Opaque for generic key-value secrets
data:
# Each key-value pair represents a secret.
# The values should be base64 encoded.
# Example:
# my_password: $(echo -n "mysecretpassword" | base64)
#
# IMPORTANT: Never store plaintext secrets in your YAML file.
# Use a secure method to generate and encode the values.
#
# Example using environment variables:
# my_api_key: $(echo -n "$MY_API_KEY" | base64)
# Add your secrets here:
api_key: YOUR_VALUE_HERE # Replace with your base64 encoded API key
database_password: YOUR_VALUE_HERE # Replace with your base64 encoded database password
# Optional: You can use 'stringData' instead of 'data' to provide plaintext values.
# Kubernetes will automatically encode them to base64.
# However, it's generally recommended to encode the values beforehand for security.
#
# stringData:
# username: myuser
# password: mysecretpassword

View File

@@ -0,0 +1,25 @@
# Kubernetes Service Manifest Template
# This file defines a Kubernetes Service, which exposes your application to the network.
apiVersion: v1
kind: Service
metadata:
name: REPLACE_ME-service # Replace with your service name
namespace: default # Change if you're using a different namespace
labels:
app: REPLACE_ME # Replace with your application name
tier: frontend # Or backend, database, etc.
spec:
type: ClusterIP # Options: ClusterIP, NodePort, LoadBalancer
# ClusterIP: Exposes the service on a cluster-internal IP. Choose this if you only need access from within the cluster.
# NodePort: Exposes the service on each Node's IP at a static port (the NodePort). Choose this for external access during development.
# LoadBalancer: Exposes the service externally using a cloud provider's load balancer. Choose this for production external access.
selector:
app: REPLACE_ME # Must match the labels of your deployment's pods
ports:
- port: 80 # The port the service exposes internally
targetPort: 8080 # The port your application is listening on within the pod
protocol: TCP
name: http # Optional, but helpful for clarity
# sessionAffinity: ClientIP # Uncomment this line to enable session affinity (sticky sessions) based on the client's IP address. Useful for applications that require session persistence.
# externalTrafficPolicy: Cluster # Uncomment for LoadBalancer. Options: Cluster or Local. Local preserves the client source IP.