LFS258-LAB-Custom Resource Definition

创建crd文件

  1. 创建crd
student@ubuntu:~/crd/new$cat resourcedefinition.yaml 
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.stable.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

student@ubuntu:~/crd/new$kubectl create -f resourcedefinition.yaml 
customresourcedefinition.apiextensions.k8s.io/crontabs.stable.example.com created

2.查看crd

student@ubuntu:~/crd/new$kubectl get crd
NAME                                          CREATED AT
bgpconfigurations.crd.projectcalico.org       2018-11-28T09:42:52Z
bgppeers.crd.projectcalico.org                2018-11-28T09:42:52Z
clusterinformations.crd.projectcalico.org     2018-11-28T09:42:52Z
crontabs.stable.example.com                   2018-12-07T03:07:33Z

student@ubuntu:~/crd/new$kubectl describe crd crontabs.stable.example.com 
Name:         crontabs.stable.example.com
Namespace:    
Labels:       <none>
Annotations:  <none>
API Version:  apiextensions.k8s.io/v1beta1
Kind:         CustomResourceDefinition
Metadata:
  Creation Timestamp:  2018-12-07T03:07:33Z
  Generation:          1

3.创建crontab

student@ubuntu:~/crd/new$cat my-crontab.yaml 
apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image


student@ubuntu:~/crd/new$kubectl create -f my-crontab.yaml 
crontab.stable.example.com/my-new-cron-object created

4.查看crontab

student@ubuntu:~/crd/new$kubectl get crontabs.stable.example.com my-new-cron-object 
NAME                 AGE
my-new-cron-object   49s

5.删除crontab

student@ubuntu:~/crd/new$kubectl delete -f my-crontab.yaml 
crontab.stable.example.com "my-new-cron-object" deleted

student@ubuntu:~/crd/new$kubectl get crontabs.stable.example.com 
No resources found.
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 前一天学习了 at 命令是针对仅运行一次的任务,循环运行的例行性计划任务,linux系统则是由 cron (cro...
    Zcclucky阅读 3,655评论 0 0
  • Linux定时任务Crontab命令详解 linux 系统则是由 cron (crond) 这个系统服务来控制的。...
    孙燕超阅读 5,795评论 0 4
  • 零、crond简介与Linux下的任务调度 crond简介 crontab命令常见于Unix和类Unix的操作系统...
    侯祥胡阅读 3,680评论 0 0
  • 为什么今天想写这个主题呢?因为这几天,我深深感受到真诚是如何打动到我的。 也许是因为光环效应,我们都对长得好看,家...
    小Kikki阅读 4,223评论 2 0
  • 深拷贝: 复制的同时开辟了新的内存存放数据; 浅拷贝:复制的时候没有开辟新内存存放数据; 具体体现为 浅拷贝 多个...
    Journey_L阅读 1,409评论 0 0

友情链接更多精彩内容