当前位置: 首页 > news >正文

Calicoctl工具学习 —— 筑梦之路

官方文档:

Calico Documentation | Calico Documentation

插件方式安装 calicoctl 工具

curl -o kubectl-calico -O -L  "https://github.com/projectcalico/calicoctl/releases/download/v3.20.0/calicoctl"cp kubectl-calico /usr/bin/kubectl-calicochmod +x /usr/bin/kubectl-calicokubectl calico -h
Usage:kubectl-calico [options] <command> [<args>...]create       Create a resource by file, directory or stdin.replace      Replace a resource by file, directory or stdin.apply        Apply a resource by file, directory or stdin.  This creates a resourceif it does not exist, and replaces a resource if it does exists.patch        Patch a pre-exisiting resource in place.delete       Delete a resource identified by file, directory, stdin or resource type andname.get          Get a resource identified by file, directory, stdin or resource type andname.label        Add or update labels of resources.convert      Convert config files between different API versions.ipam         IP address management.node         Calico node management.version      Display the version of this binary.export       Export the Calico datastore objects for migrationimport       Import the Calico datastore objects for migrationdatastore    Calico datastore management.Options:-h --help                 Show this screen.-l --log-level=<level>    Set the log level (one of panic, fatal, error,warn, info, debug) [default: panic]--context=<context>       The name of the kubeconfig context to use.--allow-version-mismatch  Allow client and cluster versions mismatch.Description:The calico kubectl plugin is used to manage Calico network and securitypolicy, to view and manage endpoint configuration, and to manage a Caliconode instance.See 'kubectl-calico <command> --help' to read about a specific subcommand.

calicoctl 是用来管理 calico 自己引入的 API 资源的。calicoctl 使用来专门操作 API Server 或 etcd 中与自己状态相关的数据的命令行工具。

calicoctl 配置文件

calicoctl 与 API Server 通信时是需要 kubeconfig 文件的,所以需要为其提供 kubeconfig 配置文件,当其作为 kubectl 的插件运行时,系统会默认读取 kubectl 的配置文件。

官方文档:https://docs.projectcalico.org/getting-started/clis/calicoctl/configure/

calico 的配置文件默认在 /etc/calico目录下,需要手动创建

mkdir /etc/calicocd /etc/calico# 在此目录下创建一个 calicoctl.cfg 的配置文件,再其内部申明后端存储类型,和 kubeconfig 的文件路径vim calicoctl.cfgapiVersion: projectcalico.org/v3
kind: CalicoAPIConfig
metadata:
spec:datastoreType: "kubernetes"        # 此处申明后端存储为kuberneteskubeconfig: "/root/.kube/config"   # 因为后端存储为k8s,所以需要kubeconfig文件来指明k8s集群地址已经认证信息。

calicoctl 使用

kubectl calico get nodes# calico 也能使用 get nodes 此处的 nodes 并非 k8s 节点,而是 calico 的资源# 此前使用 kubectl get ippools -o yaml 来获取,现在直接使用以下命令即可kubectl calico get ippool# calico 支持多个地址池,当一个地址池用完时,可以增加一个地址池
# 只不过跨网段通信略微麻烦# 查看指定地址池的资源抽象信息kubectl calico get ippool -o yaml
apiVersion: projectcalico.org/v3
items:
- apiVersion: projectcalico.org/v3kind: IPPoolmetadata:creationTimestamp: "2024-05-06T06:00:24Z"name: default-ipv4-ippoolresourceVersion: "6789"uid: 943b85b2-9759-49ce-8f73-78f1f3f8a111spec:blockSize: 24cidr: 192.168.0.0/16ipipMode: AlwaysnatOutgoing: truenodeSelector: all()vxlanMode: Never
kind: IPPoolList
metadata:resourceVersion: "7984"
ipam 子命令# 查看地址分配信息kubectl calico ipam show# 查看每个节点上的地址分配信息kubectl calico ipam show --show-blocks# 查看 ipam 配置信息kubectl calico ipam show --show-configuration+--------------------+-------+
|      PROPERTY      | VALUE |
+--------------------+-------+
| StrictAffinity     | false |   # pod被重建后是否使用原有地址
| AutoAllocateBlocks | true  |   # 是否支持自动分配地址
| MaxBlocksPerHost   |     0 |
+--------------------+-------+

 

http://www.lryc.cn/news/394150.html

相关文章:

  • Wormhole Filters: Caching Your Hash on Persistent Memory——泛读笔记
  • PyTorch学习之torch.transpose函数
  • Git仓库介绍
  • 人工智能笔记分享
  • 秋招提前批面试经验分享(上)
  • [AIGC] ClickHouse的表引擎介绍
  • 关于新装Centos7无法使用yum下载的解决办法
  • OpenEarthMap:全球高分辨率土地覆盖制图的基准数据集(开源来下载!!!)
  • 工作助手VB开发笔记(1)
  • WAWA鱼曲折的大学四年回忆录
  • Go 依赖注入设计模式
  • 使用React复刻ThreeJS官网示例——keyframes动画
  • 嵌入式linux面试1
  • 智能交通(3)——Learning Phase Competition for Traffic Signal Control
  • 【扩散模型】LCM LoRA:一个通用的Stable Diffusion加速模块
  • 【PYG】pytorch中size和shape有什么不同
  • 备份服务器出错怎么办?
  • 数据库(表)
  • Feign-未完成
  • # [0705] Task06 DDPG 算法、PPO 算法、SAC 算法【理论 only】
  • Open3D 点云CPD算法配准(粗配准)
  • 04-ArcGIS For JavaScript的可视域分析功能
  • Nestjs基础
  • DDL:针对于数据库、数据表、数据字段的操作
  • 昇思学习打卡-5-基于Mindspore实现BERT对话情绪识别
  • Java中 普通for循环, 增强for循环( foreach) List中增删改查的注意事项
  • 昇思25天学习打卡营第19天|LSTM+CRF序列标注
  • 微服务: 初识 Spring Cloud
  • 探索InitializingBean:Spring框架中的隐藏宝藏
  • JVM专题之垃圾收集算法