Skip to content

Commit

Permalink
feat: support make docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin committed Jan 23, 2024
1 parent 58c26f8 commit e3067da
Show file tree
Hide file tree
Showing 19 changed files with 459 additions and 14 deletions.
109 changes: 109 additions & 0 deletions 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
apiVersion: v1
kind: Pod
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"app":"jiaozifs-backend-api","apptype":"jiaozifs-api"},"name":"jiaozifstest","namespace":"jiaozifs"},"spec":{"containers":[{"args":["--db postgres://admin:psltest@jiaozifs-api-db-service.jiaozifs.svc.cluster.local:5432/postgresdb?sslmode=disable --log-level debug --bs_path /app/data --listen http://0.0.0.0:34913 --config /app/config.toml"],"image":"gitdatateam/jzfs:latest","imagePullPolicy":"Always","name":"jiaozifs-backend","ports":[{"containerPort":34913,"protocol":"TCP"}]}]}}
creationTimestamp: "2024-01-19T13:01:17Z"
labels:
app: jiaozifs-backend-api
apptype: jiaozifs-api
name: jiaozifstest
namespace: jiaozifs
resourceVersion: "1046785"
uid: 65b9d4c1-b0fc-4af8-a999-4f0c707543b0
spec:
containers:
- args:
- --db postgres://admin:psltest@jiaozifs-api-db-service.jiaozifs.svc.cluster.local:5432/postgresdb?sslmode=disable
--log-level debug --bs_path /app/data --listen http://0.0.0.0:34913 --config
/app/config.toml
image: gitdatateam/jzfs:latest
imagePullPolicy: Always
name: jiaozifs-backend
ports:
- containerPort: 34913
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-t5s4h
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: k3
preemptionPolicy: PreemptLowerPriority
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: kube-api-access-t5s4h
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2024-01-19T13:01:17Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2024-01-19T13:01:21Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2024-01-19T13:01:21Z"
status: "True"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2024-01-19T13:01:17Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: docker://44953ac2b21fe99ea6eb72870acdbf59d6612a4d01194b7259ee907d81212cc1
image: gitdatateam/jzfs:latest
imageID: docker-pullable://gitdatateam/jzfs@sha256:2b3b3bde619609ca845684874d67ccbd3f0fcb4206427901bc8be485d36a2daa
lastState: {}
name: jiaozifs-backend
ready: true
restartCount: 0
started: true
state:
running:
startedAt: "2024-01-19T13:01:21Z"
hostIP: 172.16.0.81
phase: Running
podIP: 10.42.1.19
podIPs:
- ip: 10.42.1.19
qosClass: BestEffort
startTime: "2024-01-19T13:01:17Z"
126 changes: 126 additions & 0 deletions 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2024-01-19T13:27:10Z"
generateName: jiaozifs-backend-api-deployment-864f944b45-
labels:
app: jiaozifs-backend-api
apptype: jiaozifs-api
pod-template-hash: 864f944b45
name: jiaozifs-backend-api-deployment-864f944b45-ghjrl
namespace: jiaozifs
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: ReplicaSet
name: jiaozifs-backend-api-deployment-864f944b45
uid: 486bd632-61ab-4245-8ac0-c8e905d2d431
resourceVersion: "1057080"
uid: b7b61713-df10-4c77-ba6f-e458ab6b7674
spec:
containers:
- args:
- --db postgres://admin:psltest@jiaozifs-api-db-service.jiaozifs.svc.cluster.local:5432/postgresdb
--log-level debug --bs_path /app/data --listen http://0.0.0.0:34913 --config
/app/config.toml
image: gitdatateam/jzfs:latest
imagePullPolicy: Always
name: jiaozifs-backend
ports:
- containerPort: 34913
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-225t9
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: k3
preemptionPolicy: PreemptLowerPriority
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: kube-api-access-225t9
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2024-01-19T13:27:10Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2024-01-19T13:27:10Z"
message: 'containers with unready status: [jiaozifs-backend]'
reason: ContainersNotReady
status: "False"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2024-01-19T13:27:10Z"
message: 'containers with unready status: [jiaozifs-backend]'
reason: ContainersNotReady
status: "False"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2024-01-19T13:27:10Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: docker://ef199f6d332d957859472e55424301153f7cb660eb936b950f3b0a891b63cfea
image: gitdatateam/jzfs:latest
imageID: docker-pullable://gitdatateam/jzfs@sha256:2b3b3bde619609ca845684874d67ccbd3f0fcb4206427901bc8be485d36a2daa
lastState:
terminated:
containerID: docker://ef199f6d332d957859472e55424301153f7cb660eb936b950f3b0a891b63cfea
exitCode: 1
finishedAt: "2024-01-19T13:27:56Z"
reason: Error
startedAt: "2024-01-19T13:27:56Z"
name: jiaozifs-backend
ready: false
restartCount: 3
started: false
state:
waiting:
message: back-off 40s restarting failed container=jiaozifs-backend pod=jiaozifs-backend-api-deployment-864f944b45-ghjrl_jiaozifs(b7b61713-df10-4c77-ba6f-e458ab6b7674)
reason: CrashLoopBackOff
hostIP: 172.16.0.81
phase: Running
podIP: 10.42.1.20
podIPs:
- ip: 10.42.1.20
qosClass: BestEffort
startTime: "2024-01-19T13:27:10Z"
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:22.04


WORKDIR /app

COPY jzfs /jzfs
COPY script/start.sh /start.sh

RUN chmod +x /start.sh

ENTRYPOINT ["/start.sh"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ After following the above steps, you should be able to see an executable file na
./jzfs daemon
```

#### run with docker
```bash
docker run -v <data>:/app -p 34913:34913 gitdatateam/jzfs:latest --db "postgres://<user>:<password>@192.168.1.16:5432/jiaozifs?sslmode=disable" --bs_path /app/data --listen http://0.0.0.0:34913 --config /app/config.toml
```
## License

Dual-licensed under [MIT](https://github.com/jiaozifs/jiaozifs/blob/main/LICENSE-MIT) + [Apache 2.0](https://github.com/jiaozifs/jiaozifs/blob/main/LICENSE-APACHE)
13 changes: 13 additions & 0 deletions charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
name: jiaozifs-api
description: Install jiaozifs api to provider backend function of jiaozifs.
version: 1.0.0
kubeVersion: < 1.28.0-0
home: https://jiaozifs.com/
keywords:
- jiaozifs
sources:
- https://github.com/jiaozifs/jiaozifs
- https://github.com/jiaozifs/jiaozifs-ui
maintainers:
- name: jiaozifs team
24 changes: 24 additions & 0 deletions charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: jiaozifs-backend-api-deployment
labels:
apptype: jiaozifs-api
spec:
replicas: 1
selector:
matchLabels:
app: jiaozifs-backend-api
template:
metadata:
labels:
app: jiaozifs-backend-api
apptype: jiaozifs-api
spec:
containers:
- name: jiaozifs-backend
image: gitdatateam/jzfs:latest
imagePullPolicy: Always
args: ["--db {{ .Values.db }} --log-level {{ .Values.log_level }} --bs_path {{ .Values.bs_path }} --listen http://0.0.0.0:{{ .Values.port }} --config {{ .Values.config }}"]
ports:
- containerPort: {{ .Values.port }}
28 changes: 28 additions & 0 deletions charts/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: jiaozifs-api
annotations:
meta.helm.sh/release-name: jiaozifs-api
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-connect-timeout: "30"
nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"
nginx.ingress.kubernetes.io/proxy-send-timeout: "1800"
labels:
apptype: jiaozifs-api
app.kubernetes.io/managed-by: Helm
heritage: Helm
release: jiaozifs-api
spec:
ingressClassName: {{.Values.ingress_name}}
rules:
- host: api.jiaozifs.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: jiaozifs-backend-api-service
port:
number: {{ .Values.port }}
14 changes: 14 additions & 0 deletions charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: jiaozifs-backend-api-service
labels:
apptype: jiaozifs-api
spec:
type: ClusterIP
selector:
app: jiaozifs-backend-api
ports:
- protocol: TCP
port: {{ .Values.port }}
targetPort: {{ .Values.port }}
10 changes: 10 additions & 0 deletions charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Additional Trusted CAs.
# Enable this flag and add your CA certs as a secret named tls-ca-additional in the namespace.
# See README.md for details.
replicas: 1
db: ""
bs_path: "/app/data"
config: "/app/config.toml"
port: 34913
ingress_name: nginx
log_level: info
14 changes: 8 additions & 6 deletions cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"context"

"github.com/pelletier/go-toml/v2"

"github.com/gorilla/sessions"
logging "github.com/ipfs/go-log/v2"
apiImpl "github.com/jiaozifs/jiaozifs/api/api_impl"
Expand All @@ -16,7 +18,6 @@ import (
"github.com/jiaozifs/jiaozifs/utils"
"github.com/jiaozifs/jiaozifs/version"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/uptrace/bun"
)

Expand All @@ -38,6 +39,12 @@ var daemonCmd = &cobra.Command{
return err
}

cfgData, err := toml.Marshal(cfg)
if err != nil {
return err
}

Check warning on line 45 in cmd/daemon.go

View check run for this annotation

Codecov / codecov/patch

cmd/daemon.go#L44-L45

Added lines #L44 - L45 were not covered by tests
log.Debug(string(cfgData))

shutdown := make(utils.Shutdown)
stop, err := fx_opt.New(cmd.Context(),
fx_opt.Override(new(context.Context), cmd.Context()),
Expand Down Expand Up @@ -76,9 +83,4 @@ var daemonCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(daemonCmd)
daemonCmd.Flags().String("db", "", "pg connection string eg. postgres://user:pass@localhost:5432/jiaozifs?sslmode=disable")
daemonCmd.Flags().String("log-level", "INFO", "set log level eg. DEBUG INFO ERROR")

_ = viper.BindPFlag("database.connection", daemonCmd.Flags().Lookup("db"))
_ = viper.BindPFlag("log.level", daemonCmd.Flags().Lookup("log-level"))
}
Loading

0 comments on commit e3067da

Please sign in to comment.