分享个好玩的,在k8s上部署web版macos

参考github上这个项目dockur/macos

先拉取docker镜像

docker pull dockurr/macos

使用这个yaml文件进行部署

复制代码
apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    pv.kubernetes.io/bound-by-controller: "yes"
    name: macos-pvc
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 64Gi
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: macos-pvc
    namespace: macos
  hostPath:
    path: /data/macos
    type: DirectoryOrCreate
  persistentVolumeReclaimPolicy: Retain
  volumeMode: Filesystem

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: macos-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 64Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: macos
  labels:
    name: macos
spec:
  terminationGracePeriodSeconds: 120 # the Kubernetes default is 30 seconds and it may be not enough
  containers:
    - name: macos
      image: dockurr/macos
      ports:
        - containerPort: 8006
          protocol: TCP
        - containerPort: 5000
          protocol: TCP
        - containerPort: 5000
          protocol: UDP
      securityContext:
        privileged: true
      env:
        - name: RAM_SIZE
          value: 4G
        - name: CPU_CORES
          value: "2"
        - name: DISK_SIZE
          value: "64G"
      volumeMounts:
        - mountPath: /storage
          name: storage
        - mountPath: /dev/kvm
          name: dev-kvm
  volumes:
    - name: storage
      persistentVolumeClaim:
        claimName: macos-pvc
    - name: dev-kvm
      hostPath:
        path: /dev/kvm
---
apiVersion: v1
kind: Service
metadata:
  name: macos
spec:
  type: NodePort
  selector:
    name: macos
  ports:
    - name: tcp-8006
      protocol: TCP
      port: 8006
      targetPort: 8006
    - name: tcp-5900
      protocol: TCP
      port: 5900
      targetPort: 5900
    - name: udp-5900
      protocol: UDP
      port: 5900
      targetPort: 5900

等待部署完成,查找service的端口

访问页面,使用VNC桌面有点卡顿

相关推荐
liangshanbo12155 小时前
前端面试题:AI 对话中超长消息导致内存溢出,怎么解决?
java·开发语言·前端
律宏阔5 小时前
Dart FFI 内存管理:用 using + Arena 替代嵌套 try-finally
前端·flutter
guslegend5 小时前
脚手架入门:必要性、核心功能与执行原理
前端·架构·node.js·脚手架·前端工程化
dawnsky.liu5 小时前
OpenShift - 实现系统负载和业务负载分区隔离
kubernetes·openshift
律宏阔5 小时前
Flutter 调用 Go:从 c-shared + ffigen 到 @Native + Native Assets 踩坑记录
前端·flutter
LEE5 小时前
前端转型全栈 05:SQL 与迁移,AI 写的 SQL 怎么安全上线
前端·后端·ai编程
用户15741568165345 小时前
macOS 打包体积异常的排查实录
前端
数据掘金5 小时前
小程序埋点方案上线前要检查哪些点?我用一张检查清单过了二十多项
前端
Hooray5 小时前
后台管理框架存活率大调查(2026版)
前端
律宏阔5 小时前
Dart FFI 回调无法使用局部变量?使用 NativeCallable.isolateLocal
前端·flutter