Skip to content

Commit

Permalink
add example for user test raven cloud-edge comm
Browse files Browse the repository at this point in the history
  • Loading branch information
TianTianBigWang committed Oct 31, 2022
1 parent a003fdd commit 99d84d2
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 3 deletions.
2 changes: 2 additions & 0 deletions core/assistant/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ func applyConfigMap(
return common.ApplyResource(ctx, resourceInter, obj)
}

//nolint
func setCurrentToMap(data map[string]interface{}, current map[string]interface{}, keys ...string) {
for _, k := range keys {
if v, ok := current[k]; ok {
Expand Down Expand Up @@ -540,6 +541,7 @@ func applyDaemonSet(
}
}
currentContainer.Image = container.Image
currentContainer.Env = envs
current.Spec.Template.Spec.Containers[0] = currentContainer
ds = *current
}
Expand Down
11 changes: 11 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- kubectl apply -f examples/test-pod.yaml

- kubectl apply -f examples/hostname.yaml

- kubectl exec -it alpine-test -- sh

- (在容器环境内)

/ # curl hostname-svc:12345

hostname-edge-84cb45ccf4-lh89n
9 changes: 9 additions & 0 deletions example/alpine-curl.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# docker buildx build --push --platform linux/arm64,linux/amd64,linux/arm,linux/ppc64le,linux/s390x \
# -t $(REPO)/alpine-curl:$(TAG) -f alpine-curl.Dockerfile .
FROM alpine:latest

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
apk update && \
apk add --no-cache curl

CMD ["tail", "-f", "/dev/null"]
44 changes: 44 additions & 0 deletions example/hostname.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hostname-edge
labels:
app: hostname-edge
spec:
replicas: 1
selector:
matchLabels:
app: hostname-edge
template:
metadata:
labels:
app: hostname-edge
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/edge
operator: Exists
- key: node-role.kubernetes.io/agent
operator: Exists
containers:
- name: hostname
image: a526102465/serve_hostname:v0.1-diplomat
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9376
---
apiVersion: v1
kind: Service
metadata:
name: hostname-svc
spec:
selector:
app: hostname-edge
ports:
- name: http-0
port: 12345
protocol: TCP
targetPort: 9376
37 changes: 37 additions & 0 deletions example/test-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: v1
kind: Pod
metadata:
name: alpine-test
spec:
containers:
- name: alpine-curl
image: a526102465/alpine-curl:v0.1-diplomat
imagePullPolicy: IfNotPresent
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/edge
operator: DoesNotExist
- key: node-role.kubernetes.io/agent
operator: DoesNotExist
---
apiVersion: v1
kind: Pod
metadata:
name: websocket-test
spec:
containers:
- name: websocket
image: a526102465/websocket_echo:v0.1-diplomat
imagePullPolicy: IfNotPresent
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/edge
operator: DoesNotExist
- key: node-role.kubernetes.io/agent
operator: DoesNotExist
44 changes: 44 additions & 0 deletions example/websocket.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ws-edge
labels:
app: ws-edge
spec:
replicas: 1
selector:
matchLabels:
app: ws-edge
template:
metadata:
labels:
app: ws-edge
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/edge
operator: Exists
- key: node-role.kubernetes.io/agent
operator: Exists
containers:
- name: ws
image: a526102465/websocket_echo:v0.1-diplomat
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: ws-svc
spec:
selector:
app: ws-edge
ports:
- name: http-0
port: 12348
protocol: TCP
targetPort: 8080
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/99nil/dsync v0.0.0-00010101000000-000000000000
github.com/99nil/gopkg v0.0.0-20220607055250-e19b23d7661a
github.com/AlecAivazis/survey/v2 v2.3.6
github.com/docker/docker v20.10.12+incompatible
github.com/go-chi/chi v1.5.4
github.com/kubeedge/kubeedge v1.11.2
github.com/natefinch/lumberjack v2.0.0+incompatible
Expand Down Expand Up @@ -38,7 +39,6 @@ require (
github.com/dgraph-io/badger/v3 v3.2103.2 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.12+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Get() Version {
}
}

func (v Version) String() string {
func (v *Version) String() string {
return fmt.Sprintf(`version: %s
assistant: %s
kubeedge: %s
Expand All @@ -67,7 +67,7 @@ platform: %s
)
}

func (v Version) EdgeString() string {
func (v *Version) EdgeString() string {
if v.Version == "" {
v.Version = "dev"
}
Expand Down

0 comments on commit 99d84d2

Please sign in to comment.