플러그인(Plugins)

헬름 + 쿠버네티스 가이드북
이민석's avatar
Jun 02, 2024
플러그인(Plugins)

헬름 + 쿠버네티스 가이드북은 Bharath Thippireddy의 Helm Kubernetes Packaging Manager for Developers and DevOps을 보고 작성되었습니다.

가이드북의 전체 목차 및 인덱싱은 헬름 + 쿠버네티스 가이드북 문서를 참고해주세요.

개요

  1. 플러그인이란?
     

플러그인이란?

헬름에 없는 기능을 필요로 할 때, 누군가 개발해둔 헬름 플러그인(Helm Puglin)을 사용할 수 있습니다.

예제 플러그인으로 살펴보기

  • salesforce/helm-starter (github) — plugin.yaml

    # Copyright (c) 2018, salesforce.com, inc.
    # All rights reserved.
    # SPDX-License-Identifier: BSD-3-Clause
    # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
    
    name: "starter"
    version: "1.0.0"
    usage: "Fetch, list, and delete helm starters from github."
    description: |-
      This plugin fetches, lists, and deletes helm starters from github.
    ignoreFlags: false
    useTunnel: false
    command: "$HELM_PLUGIN_DIR/starter.sh"

  • salesforce/helm-starter (github) — starter.sh

    #!/bin/bash
    # Copyright (c) 2018, salesforce.com, inc.
    # All rights reserved.
    # SPDX-License-Identifier: BSD-3-Clause
    # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
    
    set -e
    
    usage() {
    cat << EOF
    Fetch, list, and delete helm starters from github.
    
    Available Commands:
        helm starter fetch GITURL       Install a bare Helm starter from Github (e.g git clone)
        helm starter list               List installed Helm starters
        helm starter update NAME        Refresh an installed Helm starter
        helm starter delete NAME        Delete an installed Helm starter
        helm starter inspect NAME       Print out a starter's readme
        --help                          Display this text
    EOF
    }
    
    # Create the passthru array
    PASSTHRU=()
    while [[ $# -gt 0 ]]
    do
    key="$1"
    
    # Parse arguments
    case $key in
        --help)
        HELP=TRUE
        shift # past argument
        ;;
        *)    # unknown option
        PASSTHRU+=("$1") # save it in an array for later
        shift # past argument
        ;;
    esac
    done
    
    # Restore PASSTHRU parameters
    set -- "${PASSTHRU[@]}" 
    
    # Show help if flagged
    if [ "$HELP" == "TRUE" ]; then
        usage
        exit 0
    fi
    
    # COMMAND must be either 'fetch', 'list', or 'delete'
    COMMAND=${PASSTHRU[0]}
    
    # Create the /starters directory, if needed
    mkdir -p ${HELM_DATA_HOME}/starters
    
    if [ "$COMMAND" == "fetch" ]; then
        REPO=${PASSTHRU[1]}
        cd ${HELM_DATA_HOME}/starters
        git clone ${REPO} --quiet
        exit 0
    elif [ "$COMMAND" == "update" ]; then
        STARTER=${PASSTHRU[1]}
        cd ${HELM_DATA_HOME}/starters/${STARTER}
        git pull origin $(git rev-parse --abbrev-ref HEAD) --quiet
        exit 0
    elif [ "$COMMAND" == "list" ]; then
        ls -A1 ${HELM_DATA_HOME}/starters
        exit 0
    elif [ "$COMMAND" == "delete" ]; then 
        STARTER=${PASSTHRU[1]}
        rm -rf ${HELM_DATA_HOME}/starters/${STARTER}
        exit 0
    elif [ "$COMMAND" == "inspect" ]; then 
        STARTER=${PASSTHRU[1]}
        find ${HELM_DATA_HOME}/starters/${STARTER} -type f -iname "*readme*" -exec cat {} \;
        exit 0
    else
        echo "Error: Invalid command."
        usage
        exit 1
    fi

플러그인 명령어들

helm plugin list
helm plugin install https://github.com/salesforce/helm-starter.git
helm plugin update starter

helm starter fetch GITHUB
helm starter update NAME
helm starter delete NAME
helm starter inspect NAME
Share article

Unchaptered