Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev support GitHub directory #33

Merged
merged 2 commits into from
Jul 9, 2021
Merged

Conversation

intelliguy
Copy link
Contributor

@intelliguy intelliguy commented Jun 17, 2021

내용
현재 사용하는 manifest는 helm repo에 저장된 chart를 기반으로 돌아가도록 되어있다.
개발의 편의성을 위해 github이나 local에 올라간 소스를 기반으로 배포하는 것을 위한 유틸리티가 있다면 좋겠다.

수행내역
spec.chart를 재정의해서 필요한 기능을 수행할수 있도록 제반 유틸리티 수정

type: helmrepo
repository: https://prometheus-community.github.io/helm-charts
name: kube-prometheus-stack
version: 14.5.0

또는

type: git
repository: [email protected]:helm/charts
name: charts/stable/prometheus-operator
version: master 

와 같이 정의 가능하고 type은 생략할 수 있고 기본값 helmrepo로 산정되어 작업됨

type이 git이면 repository는 git 과 같은 의미 name은 path와 같은 의미 version은 ref와 같은 의미로 동작하도록 한다.

산출물
#33
openinfradev/decapod-base-yaml#87
openinfradev/kustomize-helm-transformer#30

@intelliguy intelliguy force-pushed the dev_support_github_directory branch from 1bf75e0 to 461fc20 Compare June 17, 2021 10:55
@github-actions
Copy link

This PR is stale because it has been open 3 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@github-actions github-actions bot added the Stale label Jun 20, 2021
@intelliguy intelliguy force-pushed the dev_support_github_directory branch 3 times, most recently from 8a72855 to 988e874 Compare June 21, 2021 10:14
@intelliguy intelliguy changed the title [WIP] Dev support GitHub directory Dev support GitHub directory Jun 21, 2021
@intelliguy intelliguy removed the Stale label Jun 21, 2021
@github-actions
Copy link

This PR is stale because it has been open 3 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@github-actions github-actions bot added the Stale label Jun 24, 2021
@bluejayA bluejayA removed the Stale label Jun 24, 2021
@github-actions
Copy link

This PR is stale because it has been open 3 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@Jaesang
Copy link
Contributor

Jaesang commented Jul 5, 2021

Test 방법이 무엇일까요?
decapod-site PR 체크아웃 후 다음과 같이 테스트해보았는데 에러가 발생합니다.

hanu-reference/lma/site-values.yaml에서 promethus-operator의 chart 오버라이드

 charts:
 - name: prometheus-operator
+  chart:
+    type: git
+    repository: [email protected]:helm/charts
+    name: charts/stable/prometheus-operator
+    version: master
   override:
     prometheusOperator.nodeSelector: $(nodeSelector)

render-cd.sh 수행

decapod-site]$ .github/workflows/render-cd.sh main output hanu-reference
...
+ echo '[render-cd] Rendering lma-manifest.yaml for hanu-reference site'
[render-cd] Rendering lma-manifest.yaml for hanu-reference site
++ pwd
+ docker run --rm -i -v /home/centos/workspace/openinfradev/decapod-site/hanu-reference:/hanu-reference --name kustomize-build ghcr.io/openinfradev/kustomize-helm-transformer:v1.3 kust$mize build --enable_alpha_plugins /hanu-reference/lma -o /hanu-reference/lma/lma-manifest.yaml
2021/07/05 01:15:42 Attempting plugin load from '/root/.config/kustomize/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer.so'
Error: no matches for OriginalId helm.fluxcd.io_v1_HelmRelease|~X|fed-addons; no matches for CurrentId helm.fluxcd.io_v1_HelmRelease|~X|fed-addons; failed to find unique target for pat$h helm.fluxcd.io_v1_HelmRelease|fed-addons
+ build_result=1
+ '[' 1 '!=' 0 ']'
+ exit 1

@intelliguy intelliguy force-pushed the dev_support_github_directory branch from 988e874 to 7a1eeda Compare July 5, 2021 01:54
@Jaesang
Copy link
Contributor

Jaesang commented Jul 5, 2021

차트 오버라이드를 위해서는 source: 변수를 사용해야합니다.

charts:
- name: prometheus-operator
  source:
    type: git
    repository: [email protected]:prometheus-community/helm-charts.git
    name: helm-charts/charts/kube-prometheus-stack
    version: main
  override:
    prometheusOperator.nodeSelector: $(nodeSelector)

위 site-values를 사용하여 아래 명령으로 테스트시 에러가 발생합니다.

$ sudo .github/workflows/render-cd.sh main output hanu-reference
[render-cd] dacapod branch=main, output target=output ,target site(s)=hanu-reference\n\n
...
[render-cd] Starting build manifests for 'hanu-reference' site
[render-cd] Rendering lma-manifest.yaml for hanu-reference site
2021/07/05 05:05:46 Attempting plugin load from '/root/.config/kustomize/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer.so'
[render-cd] [hanu-reference, lma] Successfully Generate Helm-Release Files!
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
WARNING: This chart is deprecated
fatal: could not read Username for 'https://github.com': No such device or address
Error: path ".temporary-clone/helm-charts/charts/kube-prometheus-stack" not found
...

override시도한 차트와 관련된 에러가 발생하는데, render-cd.sh에서 에러가 발생하는 것 같습니다.

    docker run --rm -i --net=host -v $(pwd)/$i:/$i -v $(pwd)/$outputdir:/cd --name generate ghcr.io/openinfradev/helmrelease2yaml:v1.2.0 -m $output -t -o /cd/$i/$app

@intelliguy intelliguy removed the frozen label Jul 6, 2021
@intelliguy
Copy link
Contributor Author

intelliguy commented Jul 6, 2021

git protocol을 사용하면 에러가 발생하는 문제를 내부적으로 git:~~ 를 https://~~~ 로 변경하도록 하여 수정완료
다음과 같이 적용 가능

charts:
- name: prometheus-operator
   source:
     name: charts/kube-prometheus-stack
     repository: https://github.com/prometheus-community/helm-charts.git
     type: git
     version: main
- name: eck-operator
  source:
    type: git
    repository: [email protected]:openinfradev/helm-charts
    version: main
    name: elasticsearch-operator

@Jaesang
Copy link
Contributor

Jaesang commented Jul 6, 2021

@intelliguy source 말고 chart가 맞나요?

@intelliguy
Copy link
Contributor Author

d

source 말고 chart가 맞나요?

source 네요.. transform된 파일에서 가져와서...
위에 내용도 수정했어요

@Jaesang
Copy link
Contributor

Jaesang commented Jul 6, 2021

@intelliguy 업데이트된 helmreleasetoyaml:v1.3.0 도 에러가 발생합니다.

오버라이드 차트

 charts:
 - name: prometheus-operator
+  source:
+    type: git
+    repository: [email protected]:prometheus-community/helm-charts.git
+    name: helm-charts/charts/kube-prometheus-stack
+    version: main
   override:
     prometheusOperator.nodeSelector: $(nodeSelector)

render-cd.sh 수행 결과

$ sudo .github/workflows/render-cd.sh main output hanu-reference
[render-cd] dacapod branch=main, output target=output ,target site(s)=hanu-reference\n\n
Fetch base with main branch/tag........
Cloning into 'decapod-base-yaml'...
remote: Enumerating objects: 1012, done.
remote: Counting objects: 100% (158/158), done.
remote: Compressing objects: 100% (124/124), done.
remote: Total 1012 (delta 51), reused 85 (delta 30), pack-reused 854
Receiving objects: 100% (1012/1012), 271.17 KiB | 0 bytes/s, done.
Resolving deltas: 100% (385/385), done.
mkdir: `output' 디렉토리를 만들 수 없습니다: 파일이 있습니다
[render-cd] Starting build manifests for 'hanu-reference' site
[render-cd] Rendering lma-manifest.yaml for hanu-reference site
2021/07/06 01:34:00 Attempting plugin load from '/root/.config/kustomize/plugin/openinfradev.github.com/v1/helmvaluestransformer/HelmValuesTransformer.so'
[render-cd] [hanu-reference, lma] Successfully Generate Helm-Release Files!
Unable to find image 'ghcr.io/openinfradev/helmrelease2yaml:v1.3.0' locally
v1.3.0: Pulling from openinfradev/helmrelease2yaml
0bc3020d05f1: Pull complete
a110e5871660: Pull complete
83d3c0fa203a: Pull complete
a8fd09c11b02: Pull complete
14feb89c4a52: Pull complete
70752631d778: Pull complete
be0100d82341: Pull complete
055b01fdac49: Pull complete
7e4fe414911b: Pull complete
a65c20eef0ec: Pull complete
9bb62cebb3ca: Pull complete
a1be27939fe2: Pull complete
42ecc14d5fe0: Pull complete
Digest: sha256:3d265fa963a7b1407411560535dc4d5d842a7403d225678ee39907c7ad4a178d
Status: Downloaded newer image for ghcr.io/openinfradev/helmrelease2yaml:v1.3.0
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
manifest_sorter.go:192: info: skipping unknown hook: "crd-install"
WARNING: This chart is deprecated
fatal: could not read Username for 'https://github.com': No such device or address
Error: could not find .temporary-clone/helm-charts/charts/kube-prometheus-stack: stat .temporary-clone/helm-charts/charts/kube-prometheus-stack: no such file or directory
Error: path ".temporary-clone/helm-charts/charts/kube-prometheus-stack" not found

@intelliguy
Copy link
Contributor Author

입력이 잘못됐습니다.

  1. git protocol 사용시 맨뒤에 .git은 없애야 합니다.
  2. git인경우 name에 들어가는 내용은 디렉토리 입니다. helm-charts는 repo명 이네요..
 charts:
 - name: prometheus-operator
+  source:
+    type: git
+    repository: [email protected]:prometheus-community/helm-charts.git
+    name: helm-charts/charts/kube-prometheus-stack
+    version: main
   override:
     prometheusOperator.nodeSelector: $(nodeSelector)

이 아니고

 charts:
 - name: prometheus-operator
+  source:
+    type: git
+    repository: [email protected]:prometheus-community/helm-charts
+    name: charts/kube-prometheus-stack
+    version: main
   override:
     prometheusOperator.nodeSelector: $(nodeSelector)

이 되어야 합니다.

@Jaesang
Copy link
Contributor

Jaesang commented Jul 7, 2021

.git 을 제외하고 말씀하신 예로 정상 동작하는 것은 확인하였습니다.
.git이 포함된 주소는 일반적으로 사용되는 주소라 생각되는데요, .git을 포함해서 지원하긴 힘들까요?

@intelliguy
Copy link
Contributor Author

intelliguy commented Jul 7, 2021

.git 을 제외하고 말씀하신 예로 정상 동작하는 것은 확인하였습니다.
.git이 포함된 주소는 일반적으로 사용되는 주소라 생각되는데요, .git을 포함해서 지원하긴 힘들까요?

일단 어렵지는 않습니다만...
git protocol을 표현하는 방법은 https://fluxcd.io/legacy/helm-operator/references/helmrelease-custom-resource/ 에서 예시로 드는 것처럼 3가지 표현방법 있습니다.

  1. [email protected]:org/repo,
  2. https://github.com/org/repo
  3. ssh://[email protected]:2222/org/repo.git.

그 중 현재는 첫번째와 두번째를 지원하고 있습니다.
'[email protected]:prometheus-community/helm-charts.git' 은 정식 표현형이 아니어서 억지로 지원하는 것은 맞지 않다고 보입니다.

@Jaesang
Copy link
Contributor

Jaesang commented Jul 8, 2021

fluxcd.io에서 든 예에서는 빠져있지만, 실제 깃헙에서 제공되는 SSH URL은 .git을 포함합니다.
repo에서 Code버튼을 누르면 HTTPS. SSH를 선택할 수 있고, SSH 선택시 아래의 URL이 제공됩니다.
[email protected]:openinfradev/helm-charts.git

상당수의 git repo가 github을 사용하고 있고, 관련 repo를 클론할때 브라우저에서 주는 저 URL을 쓸것이라고 예상됩니다.
(fluxcd보단 github의 사례가 더 범용적이 아닐까 합니다.)

어렵지 않다면, .git까지 지원하면 좋을것 같습니다.

@intelliguy
Copy link
Contributor Author

fluxcd.io에서 든 예에서는 빠져있지만, 실제 깃헙에서 제공되는 SSH URL은 .git을 포함합니다.
repo에서 Code버튼을 누르면 HTTPS. SSH를 선택할 수 있고, SSH 선택시 아래의 URL이 제공됩니다.
[email protected]:openinfradev/helm-charts.git

상당수의 git repo가 github을 사용하고 있고, 관련 repo를 클론할때 브라우저에서 주는 저 URL을 쓸것이라고 예상됩니다.
(fluxcd보단 github의 사례가 더 범용적이 아닐까 합니다.)

어렵지 않다면, .git까지 지원하면 좋을것 같습니다.

위에서 언급한 것처럼 두가지 케이스를 지원하고 있습니다. git protocol의 표현식 전체를 지원하기위해서는 라이브러리를 찾아서 하지 않으면 안될듯합니다. (노력대비 얻을게 없음)
위에서 요청하신 맨뒤에 .git을 추가해도 에러가 발생하지 않게하는 부분에 대해서는 처리했습니다.

@Jaesang
Copy link
Contributor

Jaesang commented Jul 9, 2021

위에서 요청하신 맨뒤에 .git을 추가해도 에러가 발생하지 않게하는 부분에 대해서는 처리했습니다.
에러만 발생하지 않는건가요? 다시해봐도 제대로 차트를 가져오지 못합니다.

fatal: could not read Username for 'https://github.com': No such device or address
Error: could not find .temporary-clone/charts/kube-prometheus-stack: stat .temporary-clone/charts/kube-prometheus-stack: no such file or directory
Error: path ".temporary-clone/charts/kube-prometheus-stack" not found

@intelliguy
Copy link
Contributor Author

위에서 요청하신 맨뒤에 .git을 추가해도 에러가 발생하지 않게하는 부분에 대해서는 처리했습니다.
에러만 발생하지 않는건가요? 다시해봐도 제대로 차트를 가져오지 못합니다.

fatal: could not read Username for 'https://github.com': No such device or address
Error: could not find .temporary-clone/charts/kube-prometheus-stack: stat .temporary-clone/charts/kube-prometheus-stack: no such file or directory
Error: path ".temporary-clone/charts/kube-prometheus-stack" not found

기존환경에서 돌리신거에요?
이미지 삭제후 실행해보세요.

sudo docker rmi ghcr.io/openinfradev/helmrelease2yaml:v1.3.0

@Jaesang
Copy link
Contributor

Jaesang commented Jul 9, 2021

이미지 지우고 .git Url도 잘 파싱되는거 확인하였습니다 =ㅂ=

@intelliguy intelliguy force-pushed the dev_support_github_directory branch from 529b5f5 to 6e5de24 Compare July 9, 2021 06:32
@intelliguy intelliguy force-pushed the dev_support_github_directory branch from 6e5de24 to 8366a88 Compare July 9, 2021 06:39
@intelliguy intelliguy merged commit 896f007 into main Jul 9, 2021
@intelliguy intelliguy deleted the dev_support_github_directory branch July 9, 2021 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants