大网数据广告活动
服务器运维问答

How do I configure storage class on an existing k0s cluster

· 52CE 我爱测

When I run kos kubectl get storageclass I notice it is not provisioned and I have to add it manually. I am little unsure though on the exact procedure. The [Documentation][https://docs.k0sproject.io/main/storage/] says k0s comes …

问题原文

原帖链接 · Golide · CC BY-SA 4.0

When I run kos kubectl get storageclass I notice it is not provisioned and I have to add it manually. I am little unsure though on the exact procedure. The [Documentation][https://docs.k0sproject.io/main/storage/] says k0s comes with OpenEBS installed. What I am unsure of is how to enable this extension in the config file.

My existing config file has this only (I assume this should be the default config file. Is this correct ?) :

spec:
  api:
    externalAddress

I have run k0s stop then amended the config file as follows:

spec:
  api:
    externalAddress
  extensions:
    storage:
      type: openebs_local_storage

After this config change I still get the same error they is no storageclass found for the cluster. Do I need to also reinstall/install k0s, am a bit unsure because the existing k0s.yaml seems to have very little config parameters as compared to the sample given in the link .

EDIT: Using Documentation I have proceeded to generate a new k0s.yaml that uses the existing default settings. Turns out it overwrites the existing k0s.yaml (given above) : I have also effected changes to the new yaml file to produce this :

apiVersion: k0s.k0sproject.io/v1beta1
kind: ClusterConfig
metadata:
  creationTimestamp: null
  name: k0s
spec:
  api:
    address: 10.XXX.XXX.XXX
    k0sApiPort: 9443
    port: 6443
    sans:
    - 10.XX.XX.XXX
    - 172.XX.XX.XXX
    - 10.XX.XX.XXX
    - 10.XX.XX.XXX
    - fe80::XXX:XXX:XXX:XXX
    - fe80::XXX:XXX:XXX:XXX
    - fe80::XXX:XXX:XXX:XXX
    - fe80::XXX:XXX:XXX:XXX
    - fe80::XXX:XXX:XXX:XXX
    - fe80::XXX:XXX:XXX:XXX
    tunneledNetworkingMode: false
  controllerManager: {}
  extensions:
    helm:
      charts: null
      repositories: null
    storage:
      create_default_storage_class: true
      type: openebs_local_storage
  images:
    calico:
      cni:
        image: docker.io/calico/cni
        version: v3.21.2
      kubecontrollers:
        image: docker.io/calico/kube-controllers

After this change I proceed to do a reinstall of the cluster (with the new config) :

k0s install controller -c /etc/k0s/k0s.yaml

but I am now getting an error :

Error: failed to install k0s service: failed to install service: Init already exists: /etc/systemd/system/k0scontroller.service

已采纳解答

原帖链接 · anarxz · CC BY-SA 4.0

I was able to reproduce your issue - in order to re-install the cluster with the new configuration for OpenEBS storage, you'll need to clean up your prior set-up:

  1. Stop the k0s service.
sudo k0s stop
  1. Reset previous installation that was done without your customized config file:
sudo k0s reset
  1. Re-install k0s with your new config file and with --enable-worker flag -> so that single node k0s with controller and worker functions will be installed again:
sudo k0s install controller --enable-worker -c /etc/k0s/k0s.yaml
  1. Start the k0s service:
sudo k0s start
  1. After a few seconds, check that two storage classes are enabled on the cluster for you to use:
sudo k0s kubectl get storageclass

The storage classes will have volumeBindingMode: WaitForFirstConsumer - meaning, that there is delay for volume binding until application pod is scheduled on the node.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-01-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。