Skip to content

Commit

Permalink
Merge pull request #96 from yjinjo/master
Browse files Browse the repository at this point in the history
Add helm chart and Dockerfile
  • Loading branch information
yjinjo authored Dec 19, 2024
2 parents cfc023b + dbe49f3 commit f870027
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 44 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/dispatch_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,70 @@ jobs:
status: ${{job.status}}
fields: repo,workflow,job
author_name: Github Action Slack

docker:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.CLOUDFORET_DEV_DOCKER_USERNAME }}
password: ${{ secrets.CLOUDFORET_DEV_DOCKER_PASSWORD }}

- name: Build and push to dockerhub
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ env.ARCH }}
push: true
tags: cloudforet/${{ github.event.repository.name }}:${{ env.VERSION }}

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REPO }}

- name: Build and push to ECR
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ env.ARCH }}
push: true
tags: ${{ secrets.ECR_REPO }}/${{ github.event.repository.name }}:${{ env.VERSION }}

- name: Notice when job fails
if: failure()
uses: 8398a7/[email protected]
with:
status: ${{job.status}}
fields: repo,workflow,job
author_name: Github Action Slack

notification:
needs: docker
runs-on: ubuntu-latest
steps:
- name: Slack
if: always()
uses: 8398a7/[email protected]
with:
status: ${{job.status}}
fields: repo,message,commit,author,action,ref,workflow,job
author_name: Github Action Slack
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Build stage
FROM golang:1.23-alpine AS builder

WORKDIR /app

# Install required build tools
RUN apk add --no-cache git

# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download

# Copy source code
COPY . .

# Build binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o cfctl .

# Final stage
FROM alpine:3.19

WORKDIR /app

# Install CA certificates for HTTPS
RUN apk --no-cache add ca-certificates

# Copy binary from builder
COPY --from=builder /app/cfctl .

# Create directory for configuration
RUN mkdir -p /root/.spaceone

# Set environment variable
ENV CFCTL_DEFAULT_ENVIRONMENT=default

# Set entrypoint
ENTRYPOINT ["/app/cfctl"]

33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# cfctl
# cfctl - Command Line Interface for SpaceONE

cfctl is a powerful command-line interface tool designed to interact with SpaceONE services. It provides a seamless way to manage and control your SpaceONE resources through the command line.

## Features

- **Dynamic Service Discovery**: Automatically discovers and interacts with available SpaceONE services
- **Multi-Environment Support**: Manages multiple environments (user/app) with easy switching
- **Secure Authentication**: Supports both user and application token-based authentication
- **Rich Output Formats**: Supports various output formats including table, yaml, json, and csv
- **Short Names**: Configurable resource aliases for faster command execution

## Installation

### Using Homebrew (macOS)

```bash
brew tap cloudforet-io/tap
brew install cfctl
```

### Manual Installation

Download the latest binary from [releases page](https://github.com/cloudforet-io/cfctl/releases)

## Quick Start

1. Initialize cfctl configuration:

```bash
cfctl setting init
```
4 changes: 2 additions & 2 deletions deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: cfctl
description: A cfctl chart for Kubernetes
type: application
version: 0.0.1
appVersion: 0.x.y
version: 1.0.0
appVersion: 1.0.7
67 changes: 29 additions & 38 deletions deploy/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
spaceone.service: {{ .Values.name }}
name: {{ .Values.name }}
namespace: {{ .Values.global.namespace | default .Release.Namespace }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
labels:
{{- include "cfctl.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicas }}
revisionHistoryLimit: 3
selector:
matchLabels:
spaceone.service: {{ .Values.name }}
{{- include "cfctl.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
spaceone.deployment.tool: helm
labels:
{{ include "spaceone.labels" . | indent 8 }}
spaceone.service: {{ .Values.name }}
{{- include "cfctl.selectorLabels" . | nindent 8 }}
spec:
{{- if .Values.serviceAccountName }}
serviceAccountName: {{ .Values.serviceAccountName }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.gracePeriod }}
{{- if .Values.imagePullSecrets}}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end}}
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
containers:
- name: {{ .Values.name }}
image: {{ .Values.image.name }}:{{ .Values.image.version }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
{{- if .Values.resources }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
volumeMounts:
- name: config
mountPath: {{ .Values.configPath }}
- name: data
mountPath: /data
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- end }}
{{- if .Values.env }}
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.env }}
env:
{{- toYaml .Values.env | nindent 12 }}
{{- end }}
volumeMounts:
- name: cfctl-data
mountPath: /root/.spaceone/
- name: environment-conf
mountPath: /root/default.yaml
subPath: default.yaml
readOnly: true
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: environment-conf
- name: config
configMap:
name: {{ .Values.name }}-environment-conf
{{ if .Values.pvc.storageClassName }}
- name: cfctl-data
name: {{ .Values.name }}-config
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Release.Namespace }}-cfctl-pvc
{{ else }}
- name: cfctl-data
claimName: {{ .Values.name }}-data
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}

{{- end }}
8 changes: 5 additions & 3 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
enabled: true
name: cfctl
namespace: spaceone
namespace: cloudforet

image:
name: spaceone/cfctl
name: cloudforet/cfctl
version: latest
imagePullPolicy: IfNotPresent
pullPolicy: IfNotPresent

replicas: 1

resources: {}
Expand Down

0 comments on commit f870027

Please sign in to comment.