K8s helm 創建自定義Chart


# 刪除之前創建的 chart
helm list
helm delete --purge redis1

# 創建自定義 chart myapp
cd ~/helm
helm create myapp

cd myapp/

# 修改 Chart.yaml
cat Chart.yaml

apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes myapp chart
name: myapp
version: 0.0.1
maintainer:
- name: klvchen
  email: klvchen@126.com
  url: http://www.klvchen.com


# 修改 values.yaml
cat values.yaml 

# Default values for myapp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 2

image:
  repository: ikubernetes/myapp
  tag: v1
  pullPolicy: IfNotPresent

service:
  type: ClusterIP
  port: 80
  targetPort: 80

ingress:
  enabled: false
  annotations: 
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: "true"
  path: /
  hosts:
    - chart-example.local
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

resources: 
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  limits:
    cpu: 100m
    memory: 128Mi
  requests:
    cpu: 100m
    memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

# 測試打包
cd ..
helm lint ./myapp
helm package myapp/

# 創建代理,注意這里需要在 myapp-0.0.1.tgz  同級上執行,這里會啟動一個web服務,端口為 8879
helm serve

# 新開一個終端,安裝
helm install --name myapp1 local/myapp

# 測試,訪問 ClusterIP
curl 10.102.91.53
#運行結果,正常:
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>

# 查看 myapp1 的狀態
helm status myapp1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM