Spinnaker Chart로 Spinnaker 실행하기
Helm은 Kubernetes의 패키지 관리자이다. Kubernetes에 컨테이너를 배포하려면 여러 가지 리소스를 구성해서 배포하게 되는데 이렇게 복잡한 애플리케이션을 미리 템플릿처럼 구성해 놓은 Chart로 쉽게 배포할 수 있는 도구이다. 여기서 Spinnaker Chart라는 것은 Helm의 Chart로 만들어진 Spinnaker를 얘기한다.
Helm 같은 경우 macOS라면 brew install kubernetes-helm로 설치할 수 있다. Kubernets위에 띄울 것이므로 minikube를 설치하거나 Docker for Mac의 Kubernetes를 활성화 해 두어야 한다.
brew를 이용해 쿠버네티스용 helm 설치 및 버전 확인
❯ brew install kubernetes-helm
❯ helm version
version.BuildInfo{Version:"v3.2.0", GitCommit:"e11...b71", GitTreeState:"clean", GoVersion:"go1.13.10"}
helm에 레파지토리 추가
(https://github.com/helm/charts)
❯ helm repo add stable https://kubernetes-charts.storage.googleapis.com/
❯ helm repo update
❯ helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com
❯ helm install spinnaker stable/spinnaker --timeout 12m
NAME: spinnaker
LAST DEPLOYED: Thu May 7 14:28:07 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. You will need to create 2 port forwarding tunnels in order to access the Spinnaker UI:
export DECK_POD=$(kubectl get pods --namespace default -l "cluster=spin-deck" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward --namespace default $DECK_POD 9000
export GATE_POD=$(kubectl get pods --namespace default -l "cluster=spin-gate" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward --namespace default $GATE_POD 8084
2. Visit the Spinnaker UI by opening your browser to: http://127.0.0.1:9000
To customize your Spinnaker installation. Create a shell in your Halyard pod:
kubectl exec --namespace default -it spinnaker-spinnaker-halyard-0 bash
For more info on using Halyard to customize your installation, visit:
https://www.spinnaker.io/reference/halyard/
For more info on the Kubernetes integration for Spinnaker, visit:
https://www.spinnaker.io/reference/providers/kubernetes-v2/
~ 2m 50s
DECK_POD=$(kubectl get pods --namespace default -l "cluster=spin-deck" -o jsonpath="{.items[0].metadata.name}")
kubectl -n spinnaker port-forward --namespace default $DECK_POD 9000 &
연결이 된 후 브라우저로 접속해 보면 실행된 SPINNAKER에 접속할 수 있다.
-- 끝 --
이 아래는 삽질의 기록....
[참고] kubectl로 pods 정보를 json으로 구하는 방법
❯ kubectl get pods -l "cluster=spin-gate" -o jsonpath="{}"
❯ kubectl get pods -l "cluster=spin-gate" -o jsonpath="{.items[0].metadata.name}"
spin-gate-86596d65fd-kzbmn
❯ helm list --all
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
spinnaker default 1 2020-05-07 14:28:07.358676 +0900 KST deployed spinnaker-1.23.3 1.16.2
설치가 오래 걸리는 등 설치를 취소해야 할 때
❯ helm list --all
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
spinnaker default 1 2020-05-07 14:17:58.529833 +0900 KST pending-install spinnaker-1.23.3 1.16.2
❯ helm uninstall spinnaker
❯ helm list --all
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
spinnaker default 1 2020-05-07 14:17:58.529833 +0900 KST uninstalling spinnaker-1.23.3 1.16.2
[helm으로 설치가 안되는 경우]
쿠버네티스에서 지원하는 API Version과 맞지 않아서 발생
## 안되서 hal 설치로 시도해 봄... 아직 성공 못함
❯ hal version list
❯ hal config version edit --version 1.20.1
+ Get current deployment
Success
+ Edit Spinnaker version
Success
Validation in halconfig:
- WARNING There is a newer version of Halyard available (1.35.3),
please update when possible
? Run 'sudo update-halyard' to upgrade
+ Spinnaker has been configured to update/install version "1.20.1".
Deploy this version of Spinnaker with `hal deploy apply`.
> sudo update-halyard
❯ hal deploy apply
+ Get current deployment
Success
_ Prep deployment
Running validation: Validating stats with HalconfigValidator
! ERROR Failed check for Namespace/spinnaker in null
Unable to connect to the server: x509: certificate signed by unknown authority
## hal provider 설정
❯ hal config provider kubernetes
+ Get current deployment
Success
+ Get the kubernetes provider
Success
+ Successfully got provider kubernetes.
KubernetesProvider()
## hal kubernetes account 추가
❯ kubectl get sa --all-namespaces | grep default
default default 1 3h23m
docker default 1 3h21m
kube-node-lease default 1 3h23m
kube-public default 1 3h23m
kube-system default 1 3h23m
❯ kubectl get sa default -o yaml
apiVersion: v1
kind: ServiceAccount
metadata:
creationTimestamp: "2020-05-15T00:28:37Z"
name: default
namespace: default
resourceVersion: "345"
selfLink: /api/v1/namespaces/default/serviceaccounts/default
uid: 37076160-c3f2-42f6-b07c-711f8c849363
secrets:
- name: default-token-l492k
❯ kubectl get secret default-token-l492k -o yaml
apiVersion: v1
data: ca.crt .......
CONTEXT=$(kubectl config current-context)
# This service account uses the ClusterAdmin role -- this is not necessary,
# more restrictive roles can by applied.
kubectl apply --context $CONTEXT \
-f https://spinnaker.io/downloads/kubernetes/service-account.yml
TOKEN=$(kubectl get secret --context $CONTEXT \
$(kubectl get serviceaccount spinnaker-service-account \
--context $CONTEXT \
-n spinnaker \
-o jsonpath='{.secrets[0].name}') \
-n spinnaker \
-o jsonpath='{.data.token}' | base64 --decode)
kubectl config set-credentials ${CONTEXT}-token-user --token $TOKEN
kubectl config set-context $CONTEXT --user ${CONTEXT}-token-user
❯ CONTEXT=$(kubectl config current-context)
hal config provider kubernetes account add spinnaker-service-account --context $CONTEXT
❯ kubectl config set-cluster ${CONTEXT} --insecure-skip-tls-verify=true \
--server=${CONTEXT}
> sudo chown $(id -u):$(id -g) $HOME/.kube/config
'IT > Spinnaker' 카테고리의 다른 글
Spinnaker blue green 배포 (0) | 2020.05.12 |
---|---|
Hylyard로 Spinnaker를 Kubernetes에 설치하기 (0) | 2019.10.29 |