Skip to content

Commit

Permalink
add luban extension
Browse files Browse the repository at this point in the history
  • Loading branch information
inksnw committed Oct 14, 2024
1 parent 9ed1729 commit f7ee88f
Show file tree
Hide file tree
Showing 21 changed files with 339 additions and 18 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Push Images
on:
push:
tags:
- '*'
jobs:
images:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.23.1
- name: Build Go code for amd64
run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o app-tool-amd64 main.go
- name: Build Go code for arm64
run: GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o app-tool-arm64 main.go
- name: Debug docker
run: echo ${{ secrets.DOCKER_USERNAME }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: kubesphere/app-tool:${{ github.ref_name }}
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM kubesphere/kubectl:v1.27.4
ARG TARGETARCH
COPY app-tool-${TARGETARCH} /usr/local/bin/app-tool
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions extensions/app-tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


26 changes: 26 additions & 0 deletions extensions/app-tool/README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 商店导入工具

## 概述

本工具用于把 helm repo 中的软件同步到应用商店中。注意, 您可以在 kubespehre 直接配置repo源使用, 参考文档

https://ask.kubesphere.io/forum/d/23922-kubesphere-411-ying-yong-shang-dian-pei-zhi-fang-fa

这个工具是把 repo 中的应用变成全局商店应用, 不是必须的操作。

## 使用方法

配置安装参数, 指定要同步的源

```bash
app-tool:
repoUrl: "https://charts.kubesphere.io/stable"
```

## 注意事项

由于商店允许多次上传并生成随机名称的应用,本工具不会处理多次执行的场景。如果您多次执行,希望清理生成的资源,请手动执行

```
kubectl delete applications.application.kubesphere.io xxx
```
23 changes: 23 additions & 0 deletions extensions/app-tool/charts/app-tool/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions extensions/app-tool/charts/app-tool/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
appVersion: 1.16.0
description: A Helm chart for Kubernetes
name: app-tool
type: application
version: 0.1.0
23 changes: 23 additions & 0 deletions extensions/app-tool/charts/app-tool/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: batch/v1
kind: Job
metadata:
name: app-tool-job
namespace: extension-app-tool
spec:
template:
metadata:
annotations:
kubesphere.io/serviceaccount-name: app-tool
spec:
serviceAccountName: app-tool-k8s
containers:
- name: app-tool-job
image: kubesphere/app-tool:1.0.0
args:
- /bin/sh
- -c
- |
app-tool --repo={{ .Values.repoUrl }} --server=http://ks-console.kubesphere-system
restartPolicy: Never
backoffLimit: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: batch/v1
kind: Job
metadata:
name: post-install-job
namespace: extension-app-tool
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
spec:
template:
spec:
containers:
- name: post-install-job
image: kubesphere/kubectl:v1.27.4
command:
- /bin/sh
- -c
- |
kubectl delete serviceaccounts.kubesphere.io app-tool -n extension-app-tool
kubectl delete globalrolebindings.iam.kubesphere.io app-tool-platform-admin
kubectl delete clusterroles.rbac.authorization.k8s.io app-tool-k8s-cluster-role
kubectl delete clusterrolebindings.rbac.authorization.k8s.io app-tool-k8s
kubectl delete serviceaccounts app-tool-k8s -n extension-app-tool
restartPolicy: Never
backoffLimit: 0
41 changes: 41 additions & 0 deletions extensions/app-tool/charts/app-tool/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: app-tool-k8s-cluster-role
rules:
- apiGroups:
- ""
resources:
- configmaps
- secrets
verbs:
- '*'
- apiGroups:
- "application.kubesphere.io"
resources:
- "*"
verbs:
- "*"

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: app-tool-k8s
namespace: extension-app-tool
subjects:
- kind: ServiceAccount
name: app-tool-k8s
namespace: extension-app-tool
roleRef:
kind: ClusterRole
name: app-tool-k8s-cluster-role
apiGroup: rbac.authorization.k8s.io

---
apiVersion: v1
kind: ServiceAccount
metadata:
name: app-tool-k8s
namespace: extension-app-tool
22 changes: 22 additions & 0 deletions extensions/app-tool/charts/app-tool/templates/token.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: kubesphere.io/v1alpha1
kind: ServiceAccount
metadata:
name: app-tool
namespace: extension-app-tool
---
apiVersion: iam.kubesphere.io/v1beta1
kind: GlobalRoleBinding
metadata:
labels:
iam.kubesphere.io/role-ref: platform-admin
name: app-tool-platform-admin
roleRef:
apiGroup: iam.kubesphere.io
kind: GlobalRole
name: platform-admin
subjects:
- apiGroup: kubesphere.io
kind: ServiceAccount
name: app-tool
namespace: extension-app-tool

1 change: 1 addition & 0 deletions extensions/app-tool/charts/app-tool/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repoUrl: "https://charts.kubesphere.io/stable"
33 changes: 33 additions & 0 deletions extensions/app-tool/extension.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: kubesphere.io/v1alpha1
name: app-tool
version: 0.1.0
displayName:
zh: 应用商店同步工具
en: App store sync tool
description:
zh: 应用商店同步工具
en: App store sync tool
home: https://kubesphere.io
sources:
- https://github.com/kubesphere
kubeVersion: ">=1.19.0-0"
ksVersion: ">=4.1.1-0"
category: dev-tools
keywords:
- dev-tools
provider:
zh:
name: "kubesphere"
email: ""
url: ""
en:
name: "kubesphere"
email: ""
url: ""
icon: ./static/favicon.svg
installationMode: HostOnly
externalDependencies:
- name: openpitrix
type: extension
version: '>= 1.0.0-0'
required: true
55 changes: 55 additions & 0 deletions extensions/app-tool/permissions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
kind: ClusterRole
rules:
- verbs:
- '*'
apiGroups:
- 'extensions.kubesphere.io'
- 'jsbundles.extensions.kubesphere.io'
resources:
- '*'
- verbs:
- '*'
apiGroups:
- ''
resources:
- 'configmaps'
- 'secrets'
- verbs:
- '*'
apiGroups:
- 'rbac.authorization.k8s.io'
resources:
- 'clusterroles'
- verbs:
- '*'
apiGroups:
- '*'
resources:
- '*'

---
kind: Role
rules:
- verbs:
- '*'
apiGroups:
- ''
- 'apps'
- 'batch'
- 'app.k8s.io'
- 'autoscaling'
resources:
- '*'
- verbs:
- '*'
apiGroups:
- 'networking.k8s.io'
resources:
- 'ingresses'
- 'networkpolicies'
- verbs:
- '*'
apiGroups:
- '*'
resources:
- '*'
1 change: 1 addition & 0 deletions extensions/app-tool/static/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extensions/app-tool/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
app-tool:
repoUrl: "https://charts.kubesphere.io/stable"

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/spf13/cobra v1.8.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/yaml v1.4.0
)

Expand Down
Loading

0 comments on commit f7ee88f

Please sign in to comment.