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

initial import to main branch #1

Merged
merged 33 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ed97136
feature. initial import
ktkfree Feb 14, 2023
337c4c4
feature. implementation appgroup
ktkfree Feb 16, 2023
0e27244
feature. cleanup files
ktkfree Feb 16, 2023
fe72be1
feature. add app-serve-app
ktkfree Feb 20, 2023
219e8da
trivial. update gitignore file
ktkfree Feb 20, 2023
d5a0851
feature. implementation asa deletion
ktkfree Feb 20, 2023
4b7a0b2
feature. implementation update for app-serve-apps
ktkfree Feb 21, 2023
8ab21f6
feature. rename contract to organization
ktkfree Feb 21, 2023
a9334a8
feature. change project to organization
ktkfree Feb 21, 2023
2a05879
feature. implementaion signin
ktkfree Feb 21, 2023
ab56bbc
feature. implementation
ktkfree Mar 2, 2023
e02cb0f
feature. implementation workflow status
ktkfree Mar 2, 2023
3a6a147
feature. remove tks client ( and move to tks-client repository )
ktkfree Mar 9, 2023
d35d1e9
minor. minor fixes
ktkfree Mar 10, 2023
7b98c7e
bugfix. add workflow parameter for creating cluster
ktkfree Mar 10, 2023
1b4f1f0
trivial. minor fixes
ktkfree Mar 13, 2023
2229ca1
feature.
ktkfree Mar 13, 2023
1c8d00b
trivial. disable argo for integration test
ktkfree Mar 14, 2023
5cd0fd9
featue. implementation application of appGroups
ktkfree Mar 17, 2023
a350ca7
feature: add keycloak client
cho4036 Mar 21, 2023
86d547f
minor change: ordering import package and formatting response message
cho4036 Mar 21, 2023
9e5b9e4
Merge pull request #2 from cho4036/dev_auth
ktkfree Mar 22, 2023
7afab1a
Change: organizationName -> organizationId
cho4036 Mar 22, 2023
d46c80b
Change: minor change for organization creating
cho4036 Mar 22, 2023
271da90
feature. implemtation cloud-setting
ktkfree Mar 23, 2023
ebdff7e
Change: minor change organizationName -> organizationId
cho4036 Mar 23, 2023
1765846
feature. add json validation module
ktkfree Mar 23, 2023
379e0f0
bugfix: Create organization and user feature
cho4036 Mar 23, 2023
43583c9
bugfix: Create organization and user feature
cho4036 Mar 23, 2023
1a6b218
bugfix: Create organization and user feature
cho4036 Mar 23, 2023
1b3c189
bugfix: Create organization and user feature
cho4036 Mar 23, 2023
031541a
Merge pull request #3 from cho4036/user_resource_api
ktkfree Mar 23, 2023
4a1c79f
trivial. minor fixes
ktkfree Mar 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build And Deploy
on:
push:
branches:
- main
- develop
env:
SERVICE: tks-api
TAG: ${{github.sha}}

jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}

- name: Build and Push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: |
sktcloud/${{env.SERVICE}}:${{env.TAG}}

- name: Setup Kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: "3.6.1"
- run: |
git config --global user.email "tks@github.com"
git config --global user.name "tks"

git clone "https://${{secrets.BOT_GITHUB_TOKEN}}@github.com/openinfradev/cicd-manifests.git"


TARGET='cicd'
if [[ ${{github.ref}} == *"develop"* ]]; then
TARGET='development'
elif [[ ${{github.ref}} == *"ft"* ]]; then
TARGET='ft'
fi
cd cicd-manifests/${SERVICE}/overlay/${TARGET}

kustomize edit set image docker.io/sktcloud/${SERVICE}:${TAG}
git add kustomization.yaml
git commit --allow-empty -m "Set image tag to ${SERVICE} ${TAG}"
git pull --rebase origin main
git push origin main --force
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build image
on:
pull_request:
branches:
- main
- develop
env:
SERVICE: tks-api
TAG: ${{github.sha}}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: build image
id: docker_build
uses: docker/build-push-action@v2
with:
push: false
tags: |
sktcloud/${{env.SERVICE}}:${{env.TAG}}
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.DS_Store

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

web
main
output
ktkfree marked this conversation as resolved.
Show resolved Hide resolved
vendor
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Build - backend
FROM --platform=linux/amd64 docker.io/library/golang:1.18-buster AS backend-build
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
RUN wget https://github.com/swaggo/swag/releases/download/v1.7.1/swag_linux_amd64.tar.gz -O - | tar -xz -C /tmp && cp /tmp/swag_linux_amd64/swag /usr/local/bin

WORKDIR /app/backend
COPY ./ .
RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/server ./cmd/server/main.go

ENV TZ=Asia/Seoul

EXPOSE 8080

WORKDIR /app/backend/bin

ENTRYPOINT ["./server"]
CMD ["-webroot","/app/backend/web"]
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.PHONY: docs
docs:
swag init -g ./cmd/server/main.go -o ./api/swagger

.PHONY: build
build:
go build -o output/tks-api ./cmd/server/main.go
go build -o output/tks ./cmd/client/main.go

.PHONY: run
run:
output/tks-api

.PHONY: test
test:
go test -v ./...

.PHONY: dev_run
dev_run:
swag init -g ./cmd/server/main.go -o ./api/swagger
go build ./cmd/server/main.go
./main
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,69 @@
# tks-api
tks-api
# TKS-API backend

### Run

```
$ go build -o server cmd/server/main.go
$ ./server
```

### Generate swagger files

```
$ make docs
```

### Dev run

```
# swagger build & build & run
$ make dev_run
```

### Configuration kubernetes config

kubernetes client 설정은 2가지 방식이 가능하다.
아래와 같이 kubeconfig path 를 parameter 로 넘기는 방식 ( 주로 local debugging 목적 )

```
$ ./sever --kubeconfig /kube/config ...
```

incluster 의 serviceAccount 를 활용한 방식 ( recommended ).
단 이 방식을 사용하기 위해서는 반드시 클러스터에서 tks::default serviceAccount에 대한 clusterrolebinding 설정이 필요하다.

```
in-cluster. 기본 view 권한 설정 ( 여기에 nodes, secrets 등은 빠져있음 )
$ kubectl create clusterrolebinding default-view --clusterrole=view --serviceaccount=default:tks
```

아래는 node 정보를 가져오기 위한 추가 rbac 설정

```
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: tks-api-test
namespace: tks
rules:
# Just an example, feel free to change it
- apiGroups: [""]
resources: ["nodes", "secrets","services","pods","namespaces","events"]
verbs: ["get", "watch", "list"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tks-api-test
namespace: tks
subjects:
- kind: ServiceAccount
name: default
namespace: tks
roleRef:
kind: ClusterRole
name: tks-api-test
apiGroup: rbac.authorization.k8s.io
```
Loading