1"use strict";(self.webpackChunktigera_docs=self.webpackChunktigera_docs||[]).push([["4922"],{75458:function(e,n,o){o.r(n),o.d(n,{frontMatter:()=>i,toc:()=>s,default:()=>h,metadata:()=>c,assets:()=>a,contentTitle:()=>r});var c=JSON.parse('{"id":"reference/calicoctl/convert","title":"calicoctl convert","description":"Command to convert contents of policy.yaml to v3 policy.","source":"@site/calico_versioned_docs/version-3.28/reference/calicoctl/convert.mdx","sourceDirName":"reference/calicoctl","slug":"/reference/calicoctl/convert","permalink":"/calico/3.28/reference/calicoctl/convert","draft":false,"unlisted":false,"editUrl":"https://github.com/tigera/docs/edit/main/calico_versioned_docs/version-3.28/reference/calicoctl/convert.mdx","tags":[],"version":"3.28","frontMatter":{"description":"Command to convert contents of policy.yaml to v3 policy."},"sidebar":"calicoSidebar","previous":{"title":"calicoctl label","permalink":"/calico/3.28/reference/calicoctl/label"},"next":{"title":"ipam","permalink":"/calico/3.28/reference/calicoctl/ipam/"}}'),t=o(37937),l=o(17869);let i={description:"Command to convert contents of policy.yaml to v3 policy."},r="calicoctl convert",a={},s=[{value:"Displaying the help text for 'calicoctl convert' command",id:"displaying-the-help-text-for-calicoctl-convert-command",level:2},{value:"Examples",id:"examples",level:3},{value:"Options",id:"options",level:3},{value:"See also",id:"see-also",level:2}];function d(e){let n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,l.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"calicoctl-convert",children:"calicoctl convert"})}),"\n",(0,t.jsxs)(n.p,{children:["This sections describes the ",(0,t.jsx)(n.code,{children:"calicoctl convert"})," command."]}),"\n",(0,t.jsxs)(n.p,{children:["Read the ",(0,t.jsx)(n.a,{href:"/calico/3.28/reference/calicoctl/overview",children:"calicoctl command line interface user reference"}),"\nfor a full list of calicoctl commands."]}),"\n",(0,t.jsx)(n.admonition,{type:"note",children:(0,t.jsxs)(n.p,{children:["The available actions for a specific resource type may be\nlimited based on the datastore used for Calico (etcdv3 / Kubernetes API).\nPlease refer to the\n",(0,t.jsx)(n.a,{href:"/calico/3.28/reference/resources/overview",children:"Resources section"}),"\nfor details about each resource type."]})}),"\n",(0,t.jsx)(n.h2,{id:"displaying-the-help-text-for-calicoctl-convert-command",children:"Displaying the help text for 'calicoctl convert' command"}),"\n",(0,t.jsxs)(n.p,{children:["Run ",(0,t.jsx)(n.code,{children:"calicoctl convert --help"})," to display the following help menu for the\ncommand."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:'Usage:\n calicoctl convert --filename=<FILENAME>\n [--output=<OUTPUT>] [--ignore-validation]\n\nExamples:\n # Convert the contents of policy.yaml to a Calico v3 policy.\n calicoctl convert -f ./policy.yaml -o yaml\n\n # Convert a policy based on the JSON passed into stdin.\n cat policy.json | calicoctl convert -f -\n\nOptions:\n -h --help Show this screen.\n -f --filename=<FILENAME> Filename to use to create the resource. If set to\n "-" loads from stdin.\n -o --output=<OUTPUT FORMAT> Output format. One of: yaml or json.\n [Default: yaml]\n --ignore-validation Skip validation on the converted manifest.\n\nDescription:\n Convert config files from Calico v1 or Kubernetes to Calico v3 API versions. Both YAML and JSON formats are accepted.\n\n The default output will be printed to stdout in YAML format.\n'})}),"\n",(0,t.jsx)(n.admonition,{type:"note",children:(0,t.jsx)(n.p,{children:"Currently the only Kubernetes API resource supported for conversion is NetworkPolicy."})}),"\n",(0,t.jsx)(n.h3,{id:"examples",children:"Examples"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Convert a set of resources (of mixed type) from Calico v1 or Kubernetes to Calico v3 APIs using the data in resources.yaml."}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"calicoctl convert -f multi-resource-v1.yaml -o yaml > multi-resource-v3.yaml\n"})}),"\n",(0,t.jsx)(n.admonition,{type:"tip",children:(0,t.jsx)(n.p,{children:"By default convert command outputs the converted resources to stdout, but it can be redirected to a file."})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Convert a policy based on the JSON passed into stdin."}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cat policy.json | calicoctl convert -f -\n"})}),"\n",(0,t.jsx)(n.p,{children:"Result will be printed to stdout."}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"options",children:"Options"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:'-f --filename=<FILENAME> Filename to use to convert the resource. If set to\n "-" loads from stdin.\n-o --output=<OUTPUT FORMAT> Output format. One of: yaml or json.\n [Default: yaml]\n--ignore-validation Skip validation on the converted manifest.\n'})}),"\n",(0,t.jsx)(n.h2,{id:"see-also",children:"See also"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/calico/3.28/operations/calicoctl/install",children:"Installing calicoctl"})}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/calico/3.28/reference/resources/overview",children:"Resources"})," for details on all valid resources, including file format\nand schema"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/calico/3.28/reference/calicoctl/get",children:"calicoctl get"})," for details on ",(0,t.jsx)(n.code,{children:"calicoctl get"})," command to get the resources."]}),"\n"]})]})}function h(e={}){let{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},17869:function(e,n,o){o.d(n,{R:()=>i,x:()=>r});var c=o(82645);let t={},l=c.createContext(t);function i(e){let n=c.useContext(l);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),c.createElement(l.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.