gpt4 book ai didi

android - 在 GKE 上运行 android 容器 - adb 未附加到设备

转载 作者:行者123 更新时间:2023-12-02 11:47:06 25 4
gpt4 key购买 nike

我正在尝试通过 GKE 运行 android 模拟器容器。为此,我使用 budtmo/docker-android开源。

首先,我尝试通过 docker 在本地运行它:

$ sudo  docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 4723:4723 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1

然后我连接到设备,使用:
$ adb connect localhost:5555

我看到了这个设备:
>> $ adb devices
List of devices attached
localhost:5555 device

效果很好!

现在我尝试在 GKE 上做同样的事情:

这是 pods :
apiVersion: v1
kind: Pod
metadata:
name: android
labels:
app: android
spec:
containers:
- name: android
image: budtmo/docker-android-x86-8.1
securityContext:
privileged: true
ports:
- containerPort: 6080
- containerPort: 5554
- containerPort: 5555
- containerPort: 4723
env:
- name: DEVICE
value: "Samsung Galaxy S6"

这是服务:
apiVersion: v1
kind: Service
metadata:
name: android-service
spec:
ports:
- port: 6080
name: serving
protocol: TCP
- port: 5555
name: srv
protocol: TCP
- port: 5554
name: srv2
protocol: TCP
- port: 4723
name: novnc
protocol: TCP
selector:
app: android
type: LoadBalancer
loadBalancerIp: "35.X.X.X"

然后我试图连接到模拟器(从我的电脑),但是在它声称它连接之后,我没有看到任何连接的设备:
>> $ adb connect 35.X.X.X:5555
connected to 35.X.X.X:5555
>> $ adb devices
List of devices attached
*empty*

我还尝试从 GKE 终端本地连接:
adb connect 35.X.X.X:5555
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
connected to 35.X.X.X:5555

再说一遍:
>> $ adb devices
List of devices attached
*empty*

知道是什么问题,我该如何解决?

最佳答案

复制了您的步骤,唯一的区别是:我没有指定 loadBalancerIp服务中:

---
apiVersion: v1
kind: Pod
metadata:
name: android
labels:
app: android
spec:
containers:
- name: android
image: budtmo/docker-android-x86-8.1
securityContext:
privileged: true
ports:
- containerPort: 6080
- containerPort: 5554
- containerPort: 5555
- containerPort: 4723
env:
- name: DEVICE
value: "Samsung Galaxy S6"

---
apiVersion: v1
kind: Service
metadata:
name: android-service
spec:
ports:
- port: 6080
name: serving
protocol: TCP
- port: 5555
name: srv
protocol: TCP
- port: 5554
name: srv2
protocol: TCP
- port: 4723
name: novnc
protocol: TCP
selector:
app: android
type: LoadBalancer

结果是使用提供的 yaml 一切正常:
kubectl get po,svc
NAME READY STATUS RESTARTS AGE
pod/android 1/1 Running 0 14m

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/android-service LoadBalancer 10.0.1.238 *.*.*.54 6080:31952/TCP,5555:30822/TCP,5554:30806/TCP,4723:30248/TCP 14m

从本地电脑:
adb connect *.*.*.54:5555
already connected to *.*.*.54:5555

adb devices
List of devices attached
*.*.*.54:5555 offline
emulator-5554 device
localhost:5555 device

关于android - 在 GKE 上运行 android 容器 - adb 未附加到设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57322523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com