mac安装dockerdesktop优化

1、安装kubenetes时很慢,需要配置国内加速(后来发现没有配置加速也挺快的) 2014年6月镜像加速个人用户不能使用了需要翻墙或自建hub仓库

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  },

  "registry-mirrors": ["https://5b6y64zz.mirror.aliyuncs.com"]
}


{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "registry-mirrors": [
    "https://5b6y64zz.mirror.aliyuncs.com"
  ]
}

2、修改参数已解决centos7无法使用systemctl(修改前centos7镜像都无法使用systemctl,修改后只有官方镜像可以使用systemctl)

deockerdesktop4.3以后为了安全把cgroupv1改成了cgroupv2,而导致centos7在dockerDesktop4.3之后无法使用systemctl,解决方法是要么使用centos8镜像,要么把cgroupv1开启,需要重启dockdesktop

具体操作如下:
编辑~/Library/Group\ Containers/group.com.docker/settings.json修改"deprecatedCgroupv1"参数为true,默认是false

deprecatedCgroupv1": true,

3、想要使用kubectl top 命令需要部署metrics-server容器

(1) 先下载好metrics-server镜像
docker pull bitnami/metrics-server:latest

(2) 下载metrics-server yaml文件并修改镜像名称/增加权限/关闭证书认证
wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
https://devpress.csdn.net/k8s/62f9a6d6c6770329307ff1e8.html
https://cloud.tencent.com/developer/article/2064852

(3) 然后启动pod
kubectl apply -f components.yaml
kubectl get pod -n kube-system

(4) 改完是这个样子
wenqiang@wq docker % cat components.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-app: metrics-server
    rbac.authorization.k8s.io/aggregate-to-admin: "true"
    rbac.authorization.k8s.io/aggregate-to-edit: "true"
    rbac.authorization.k8s.io/aggregate-to-view: "true"
  name: system:aggregated-metrics-reader
rules:
- apiGroups:
  - metrics.k8s.io
  resources:
  - pods
  - nodes
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
rules:
- apiGroups:
  - ""
  resources:           # 增加
  - nodes/metrics
  - pods
  - nodes
  - nodes/stats
  - namespaces
  verbs:               # 增加
  - get
  - list
  - watch
- apiGroups:           # 增加
  - "extensions"
  resources:           # 增加
  - pods
  - nodes
  - deployments
  verbs:                # 增加
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server-auth-reader
  namespace: kube-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server:system:auth-delegator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:auth-delegator
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:metrics-server
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:
  ports:
  - name: https
    port: 443
    protocol: TCP
    targetPort: https
  selector:
    k8s-app: metrics-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:
  selector:
    matchLabels:
      k8s-app: metrics-server
  strategy:
    rollingUpdate:
      maxUnavailable: 0
  template:
    metadata:
      labels:
        k8s-app: metrics-server
    spec:
      containers:
      - args:
        - --cert-dir=/tmp
        - --secure-port=4443
        - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
        - --kubelet-use-node-status-port
        - --metric-resolution=15s
        - --kubelet-insecure-tls     # 增加
        image: registry.k8s.io/metrics-server:latest   #修改
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /livez
            port: https
            scheme: HTTPS
          periodSeconds: 10
        name: metrics-server
        ports:
        - containerPort: 4443
          name: https
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /readyz
            port: https
            scheme: HTTPS
          initialDelaySeconds: 20
          periodSeconds: 10
        resources:
          requests:
            cpu: 100m
            memory: 200Mi
        securityContext:
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          runAsUser: 1000
        volumeMounts:
        - mountPath: /tmp
          name: tmp-dir
      nodeSelector:
        kubernetes.io/os: linux
      priorityClassName: system-cluster-critical
      serviceAccountName: metrics-server
      volumes:
      - emptyDir: {}
        name: tmp-dir
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  labels:
    k8s-app: metrics-server
  name: v1beta1.metrics.k8s.io
spec:
  group: metrics.k8s.io
  groupPriorityMinimum: 100
  insecureSkipTLSVerify: true
  service:
    name: metrics-server
    namespace: kube-system
  version: v1beta1
  versionPriority: 100
相关推荐
程序媛-徐师姐7 小时前
解决MacOS安装软件时提示“打不开xxx软件,因为Apple无法检查其是否包含恶意软件”的问题
macos·无法检查其是否包含恶意软件·打不开xxx软件
刘贤松1 天前
Mac Electron 应用签名(signature)和公证(notarization)
javascript·macos·electron
狂奔solar1 天前
Titans 架构下MAC变体的探究
macos·架构
itbysj2 天前
MacOS 如何解决无法打开 ‘xxx’,因为 Apple 无法检查其是否包含恶意软件
macos·无法打开 ‘xxx’·无法检查其是否包含恶意软件
itbysj3 天前
(2025 年最新)MacOS Redis Desktop Manager中文版下载,附详细图文
数据库·redis·macos·redis desktop
李小苶3 天前
Mac m1,m2,m3芯片使用nvm安装node14报错
macos
我是唐青枫4 天前
Mac 上如何同时运行多个MySQL版本?
mysql·macos·adb
好悬给我拽开线4 天前
【论文阅读】RT-SKETCH: GOAL-CONDITIONED IMITATION LEARNING FROM HAND-DRAWN SKETCHES
论文阅读·macos·sketch
随心但不率性4 天前
macos app签名和公证
macos·策略模式