Skip to content

Commit

Permalink
Merge pull request #43 from openinfradev/update_readme
Browse files Browse the repository at this point in the history
update README
  • Loading branch information
ktkfree authored Apr 15, 2022
2 parents f67d408 + 925ca81 commit 94b6906
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 14 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
FROM golang:1.16.3-stretch AS builder
LABEL AUTHOR Seungkyu Ahn ([email protected])

ARG PRV_GITHUB_TOKEN
RUN go env -w GOPRIVATE=github.com/openinfradev/tks-cluster-lcm
RUN git config --global url."https://x-access-token:${PRV_GITHUB_TOKEN}@github.com".insteadOf "https://github.com"

RUN mkdir -p /build
WORKDIR /build

Expand Down
82 changes: 79 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,83 @@
# tks-cluster-lcm

## Quick start
[![Go Report Card](https://goreportcard.com/badge/github.com/openinfradev/tks-cluster-lcm?style=flat-square)](https://goreportcard.com/report/github.com/openinfradev/tks-cluster-lcm)
[![Go Reference](https://pkg.go.dev/badge/github.com/openinfradev/tks-cluster-lcm.svg)](https://pkg.go.dev/github.com/openinfradev/tks-cluster-lcm)
[![Release](https://img.shields.io/github/release/sktelecom/tks-cluster-lcm.svg?style=flat-square)](https://github.com/openinfradev/tks-cluster-lcm/releases/latest)

## How to modify
TKS는 Taco Kubernetes Service의 약자로, SK Telecom이 만든 GitOps기반의 서비스 시스템을 의미합니다. 그 중 Tks-cluster-lcm은 tks cluster 및 기반 서비스들의 생성, 조회 및 삭제 등 전반적인 lifecycle을 관리하는 서비스이며, 다른 tks service들과 gRPC 기반으로 통신합니다. gRPC 호출을 위한 proto 파일은 [tks-proto](https://github.com/openinfradev/tks-proto)에서 확인할 수 있습니다.

## How to contribute
## Quick Start

### Prerequisite
* docker 20.x 설치 (docker로 구동할 경우)
* tks-info 설치
* tks-info: https://github.com/openinfradev/tks-info
* decapod component 설치
* decapod-bootstrap: https://github.com/openinfradev/decapod-bootstrap
* decapod document: https://openinfradev.github.io/decapod-docs

### 서비스 구동 (For go developers)

```
$ go build -o bin/tks-cluster-lcm ./cmd/server/
$ bin/tks-cluster-lcm -port 9110
```

### 서비스 구동 (For docker users)
```
$ docker pull sktcloud/tks-cluster-lcm
$ docker run --name tks-cluster-lcm -p 9110:9110 -d \
sktcloud/tks-cluster-lcm -port 9110
```

### gRPC API 호출 예제 (golang)

```
import (
"google.golang.org/grpc"
pb "github.com/openinfradev/tks-proto/tks_pb"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/timestamppb"
...
)
func YOUR_FUNCTION(YOUR_PARAMS...) {
var conn *grpc.ClientConn
tksInfoUrl = viper.GetString("tksInfoUrl")
if tksInfoUrl == "" {
fmt.Println("You must specify tksInfoUrl at config file")
os.Exit(1)
}
conn, err := grpc.Dial(tksInfoUrl, grpc.WithInsecure())
if err != nil {
log.Fatalf("Couldn't connect to tks-info: %s", err)
}
defer conn.Close()
client := pb.NewClusterInfoServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
data := pb.GetClustersRequest{}
data.ContractId = viper.GetString("contractId")
m := protojson.MarshalOptions{
Indent: " ",
UseProtoNames: true,
}
jsonBytes, _ := m.Marshal(&data)
r, err := client.GetClusters(ctx, &data)
if err != nil {
fmt.Println(err)
} else {
if len(r.Clusters) == 0 {
fmt.Println("No cluster exists for specified contract!")
} else {
/* print cluster info from 'r' */
}
}
}
```
8 changes: 0 additions & 8 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"flag"
"os"

"github.com/openinfradev/tks-common/pkg/argowf"
"github.com/openinfradev/tks-common/pkg/grpc_client"
Expand Down Expand Up @@ -38,7 +37,6 @@ var (
argoPort int
revision string
githubAccount string
githubToken string
)

func init() {
Expand All @@ -55,8 +53,6 @@ func init() {
flag.IntVar(&argoPort, "argo-port", 2746, "server port for argo-workflow-server")
flag.StringVar(&revision, "revision", "main", "revision for workflow parameter")
flag.StringVar(&githubAccount, "git-account", "tks-management", "git repository name for workflow parameter")

githubToken = os.Getenv("TOKEN")
}

func main() {
Expand All @@ -77,10 +73,6 @@ func main() {
log.Info("githubAccount : ", githubAccount)
log.Info("****************** ")

if githubToken = os.Getenv("TOKEN"); githubToken == "" {
log.Fatal("Specify githubToken to environment variable (TOKEN).")
}

// initialize clients
var err error
argowfClient, err = argowf.New(argoAddress, argoPort)
Expand Down

0 comments on commit 94b6906

Please sign in to comment.