\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{ITServicesTool Start-Up (ITServiceStart-Up)} \pdfinfo{ /Title (oc-cli-commands.pdf) /Creator (Cheatography) /Author (ITServicesTool Start-Up (ITServiceStart-Up)) /Subject (OC CLI commands Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{000000} \definecolor{LightBackground}{HTML}{F7F7F7} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{OC CLI commands Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{ITServicesTool Start-Up (ITServiceStart-Up)} via \textcolor{DarkBackground}{\uline{cheatography.com/32307/cs/9933/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}ITServicesTool Start-Up (ITServiceStart-Up) \\ \uline{cheatography.com/itservicestart-up} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 24th November, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Ansible}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/itservicestart-up_1479976598_images.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.14 cm} x{2.812 cm} x{3.648 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Basic CLI Operations}} \tn % Row 0 \SetRowColor{LightBackground} types & `oc types` & Display an introduction to some core OpenShift concepts \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} login & `oc login` & Log in to the OpensShift server \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{logout} & `oc logout` & End the current session \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{new-project} & `oc new-project \textless{}project\_name\textgreater{}` & Create a new project \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{new-app} & `oc new-app .` & \{\{link="https://docs.openshift.com/enterprise/3.0/dev\_guide/new\_app.html\#dev-guide-new-app"\}\}Create a new application\{\{/link\}\} based on the source code in the current directory \tn % Row Count 20 (+ 10) % Row 5 \SetRowColor{white} \seqsplit{status} & `oc status` & Show an overview of the current project \tn % Row Count 23 (+ 3) % Row 6 \SetRowColor{LightBackground} \seqsplit{project} & `oc project \textless{}project\_name\textgreater{}` & Switch to another project \tn % Row Count 25 (+ 2) % Row 7 \SetRowColor{white} list \seqsplit{projects} & `oc project` & View all projects you have access to \tn % Row Count 28 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{0.988 cm} x{3.344 cm} x{3.268 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Build and Deployment CLI Operations}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{start-build} & `oc start-build \textless{}buildConfig\_name\textgreater{}` & Manually start the build process with the specified build configuration file \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \seqsplit{start-build} & `oc start-build -{}-from-build=\textless{}build\_name\textgreater{}` & Manually start the build process by specifying the name of a previous build as a starting point \tn % Row Count 11 (+ 6) % Row 2 \SetRowColor{LightBackground} \seqsplit{start-build} & `oc start-build \textbackslash{}{[}\textless{}buildConfig\_name\textgreater{}|-{}-from-build=\textless{}build\_name\textgreater{}{]} -{}-follow` & Manually start the build process by specifying either a configuration file or the name of a previous build and retreives its build logs \tn % Row Count 19 (+ 8) % Row 3 \SetRowColor{white} \seqsplit{build-logs} & `oc build-logs \textless{}build\_name\textgreater{}` & Retreive the build logs for the specified build \tn % Row Count 22 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{deploy} & `oc deploy \textless{}deploymentconfig\textgreater{}` & View a \{\{link="https://docs.openshift.com/enterprise/3.0/dev\_guide/deployments.html\#dev-guide-deployments"\}\}deployment\{\{/link\}\}, or manually start, cancel, or retry a deployment \tn % Row Count 33 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{0.988 cm} x{3.344 cm} x{3.268 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Build and Deployment CLI Operations (cont)}} \tn % Row 5 \SetRowColor{LightBackground} \seqsplit{rollback} & `oc rollback \textless{}deployment\_name\textgreater{}` & Perform a \{\{link="https://docs.openshift.com/enterprise/3.0/dev\_guide/deployments.html\#rolling-back-a-deployment"\}\}rollback\{\{/link\}\} \tn % Row Count 8 (+ 8) % Row 6 \SetRowColor{white} \seqsplit{new-build} & `oc new-build .` & Create a build config based on the source code in the current git repository (with a public remote) and a Docker image \tn % Row Count 15 (+ 7) % Row 7 \SetRowColor{LightBackground} \seqsplit{cancel-build} & `oc cancel-build \textless{}build\_name\textgreater{}` & Stop a build that is in progres \tn % Row Count 18 (+ 3) % Row 8 \SetRowColor{white} \seqsplit{import-image} & `oc import-image \textless{}imagestream\textgreater{}` & Import tag and image information from an external Docker image repository \tn % Row Count 23 (+ 5) % Row 9 \SetRowColor{LightBackground} scale & `oc scale \textless{}object\_type\textgreater{} \textless{}object\_id\textgreater{} \textbackslash{} -{}-replicas=\textless{}\#\_of\_replicas\textgreater{}` & Set the number of desired replicas for a \{\{link="https://docs.openshift.com/enterprise/3.0/architecture/core\_concepts/deployments.html\#replication-controllers"\}\}replication controller\{\{/link\}\} or a \{\{link="https://docs.openshift.com/enterprise/3.0/dev\_guide/deployments.html\#dev-guide-deployments"\}\}deployment configuration\{\{/link\}\} to the number of specified replicas \tn % Row Count 45 (+ 22) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{0.988 cm} x{3.344 cm} x{3.268 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Build and Deployment CLI Operations (cont)}} \tn % Row 10 \SetRowColor{LightBackground} tag & `oc tag \textless{}current\_image\textgreater{} \textless{}image\_stream\textgreater{}` & Take an existing tag or image from an image stream, or a Docker image pull spec, and set it as the most recent image fro a tag in one or more other image streams \tn % Row Count 10 (+ 10) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.76 cm} x{3.42 cm} x{3.42 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Application Modification CLI Operations}} \tn % Row 0 \SetRowColor{LightBackground} get & `oc get \textless{}object\_type\textgreater{} {[}\textless{}object\_name\_or\_id\textgreater{}{]}` & Return a list of objects for the specified \{\{link="https://docs.openshift.com/enterprise/3.0/cli\_reference/basic\_cli\_operations.html\#object-types"\}\}object type\{\{/link\}\} \tn % Row Count 10 (+ 10) % Row 1 \SetRowColor{white} \seqsplit{describe} & `oc describe \textless{}object\_type\textgreater{}` & Returns information about the specific object returned by the query \tn % Row Count 14 (+ 4) % Row 2 \SetRowColor{LightBackground} edit & `oc edit \textless{}object\_type\textgreater{}/\textless{}object\_type\_name\textgreater{}` & Edit the desired object type \tn % Row Count 17 (+ 3) % Row 3 \SetRowColor{white} edit & `OC\_EDITOR="\textless{}text\_editor\textgreater{}" oc edit \textbackslash{} \textless{}object\_type\textgreater{}/\textless{}object\_type\_name\textgreater{}` & Edit the desired object type with a specified text editor \tn % Row Count 21 (+ 4) % Row 4 \SetRowColor{LightBackground} edit & `oc edit \textless{}object\_type\textgreater{}/\textless{}object\_type\_name\textgreater{} \textbackslash{} -{}-output-version=\textless{}object\_type\_version\textgreater{} \textbackslash{} -o \textless{}object\_type\_format\textgreater{}` & Edit the desired object in a specified format (e.g: JSON) \tn % Row Count 28 (+ 7) % Row 5 \SetRowColor{white} env & `oc env \textless{}object\_type\textgreater{}/\textless{}object\_type\_name\textgreater{} \textbackslash{} \textless{}EN\_VAR\textgreater{}=/\textless{}VALUE\textgreater{}` & Update the desired object type with a new environment variable \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{p{0.76 cm} x{3.42 cm} x{3.42 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Application Modification CLI Operations (cont)}} \tn % Row 6 \SetRowColor{LightBackground} \seqsplit{volume} & `oc volume \textless{}object\_type\textgreater{}/\textless{}object\_type\_name\textgreater{} \textbackslash{} {[}-{}-option{]}` & Modify a volume \tn % Row Count 4 (+ 4) % Row 7 \SetRowColor{white} label & `oc label \textless{}object\_type\textgreater{} \textless{}obejct\_name\_or\_id\textgreater{} \textbackslash{} \textless{}label\textgreater{}` & Update the labels on an object \tn % Row Count 7 (+ 3) % Row 8 \SetRowColor{LightBackground} \seqsplit{expose} & `oc expose \textless{}object\_type\textgreater{} \textless{}object\_name\_or\_id\textgreater{}` & Look up a service and expose it as a route \tn % Row Count 10 (+ 3) % Row 9 \SetRowColor{white} stop & `oc stop -f \textless{}file\_path\textgreater{}` & Gracefully shut down an object by ID or file name. \tn % Row Count 13 (+ 3) % Row 10 \SetRowColor{LightBackground} stop & `oc stop \textless{}object\_type\textgreater{} \textless{}object\_name\_or\_id\textgreater{}` & Gracefully shut down an object with the specified ID \tn % Row Count 16 (+ 3) % Row 11 \SetRowColor{white} stop & `oc stop \textless{}object\_type\textgreater{} -l \textless{}label\textgreater{}` & Gracefully shit down an object with the specified label \tn % Row Count 20 (+ 4) % Row 12 \SetRowColor{LightBackground} stop & `oc stop all -l \textless{}label\textgreater{}` & Gracefully shut down all objects with the specified label \tn % Row Count 24 (+ 4) % Row 13 \SetRowColor{white} \seqsplit{delete} & `oc delete -f \textless{}file\_path\textgreater{}` & Delete the specified object \tn % Row Count 26 (+ 2) % Row 14 \SetRowColor{LightBackground} \seqsplit{delete} & `oc delete \textless{}object\_type\textgreater{} \textless{}object\_name\_or\_id\textgreater{}` & Delete the specified object \tn % Row Count 29 (+ 3) % Row 15 \SetRowColor{white} \seqsplit{delete} & `oc delete \textless{}object\_type\textgreater{} -l \textless{}label\textgreater{}` & Delete the object matching the specified label \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{p{0.76 cm} x{3.42 cm} x{3.42 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Application Modification CLI Operations (cont)}} \tn % Row 16 \SetRowColor{LightBackground} \seqsplit{delete} & `oc delete all -l \textless{}label\textgreater{}` & Delete all object matching the specified label \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{0.988 cm} x{3.344 cm} x{3.268 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Troubleshooting and Debugging CLI Operations}} \tn % Row 0 \SetRowColor{LightBackground} logs & `oc logs -f \textless{}pod\_name\textgreater{} \textless{}container\_name\textgreater{}` & Retreive the log output for a specific pod or container. This command does not work for other object types \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} exec & `oc exec \textless{}pod\_ID\textgreater{} \textbackslash{} {[}-c \textless{}container\_ID\textgreater{}{]} \textless{}command\textgreater{}` & Execute a command in an already-running container. You can optionally specify a container ID, otherwise it defaults to the first container \tn % Row Count 16 (+ 9) % Row 2 \SetRowColor{LightBackground} rsh & `oc rsh \textless{}pod\_ID\textgreater{}` & Open a remote shell session to a container \tn % Row Count 19 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{port-forward} & `oc port-forward \textless{}pod\_ID\textgreater{} \textbackslash{} \textless{}first\_port\_ID\textgreater{} \textless{}second\_port\_ID\textgreater{}` & \{\{link="https://docs.openshift.com/enterprise/3.0/dev\_guide/port\_forwarding.html\#dev-guide-port-forwarding"\}\}Forward one or more local ports\{\{/link\}\} to a pod \tn % Row Count 29 (+ 10) % Row 4 \SetRowColor{LightBackground} proxy & `oc proxy -{}-port=\textless{}port\_ID\textgreater{} \textbackslash{} -{}-www=\textless{}static\_directory\textgreater{}` & Run a proxy to the Kubernetes AI server \tn % Row Count 33 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.76 cm} x{3.344 cm} x{3.496 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Advanced Commands}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{create} & `oc create -f \textless{}file\_or\_dir\_path\textgreater{}` & Parse a configuration file and create one or more OpenShift object based on the file contents. The `-f` flag can be passed multiple times with different file or directory paths. \tn % Row Count 10 (+ 10) % Row 1 \SetRowColor{white} \seqsplit{update} & `oc update -f \textless{}file\_or\_dir\_path\textgreater{}` & Attempt to modify an existing object based on the contents of the specified configuration file. \tn % Row Count 16 (+ 6) % Row 2 \SetRowColor{LightBackground} \seqsplit{process} & `oc process -f \textless{}template\_file\_path\textgreater{}` & Transform a project \{\{link="https://docs.openshift.com/enterprise/3.0/dev\_guide/templates.html\#dev-guide-templates"\}\}template\{\{/link\}\} into a project configuration file \tn % Row Count 26 (+ 10) % Row 3 \SetRowColor{white} \seqsplit{export} & `oc export \textless{}object\_type\textgreater{} {[}-{}-options{]}` & Export resources to be used elsewhere \tn % Row Count 29 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{policy} & `oc policy {[}-{}-options{]}` & Manage authorization policies \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{p{0.76 cm} x{3.344 cm} x{3.496 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Advanced Commands (cont)}} \tn % Row 5 \SetRowColor{LightBackground} \seqsplit{secrets} & `oc secrets {[}-{}-options{]} \seqsplit{path/to/ssh\_key`} & Configure \{\{link="https://docs.openshift.com/enterprise/3.0/dev\_guide/secrets.html\#dev-guide-secrets"\}\}secrets\{\{/link\}\} \tn % Row Count 7 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.36 cm} x{4.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Object Types}} \tn % Row 0 \SetRowColor{LightBackground} \{\{ac\}\} {\bf{Object Type}} & \{\{ac\}\} {\bf{Abbreviated Version}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{build} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} buildConfig & bc \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{deploymentConfig} & dc \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} imageStream & is \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} imageStreamTag & istag \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \seqsplit{imageStreamImage} & isimage \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} event & ev \tn % Row Count 9 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{node} \tn % Row Count 10 (+ 1) % Row 9 \SetRowColor{white} pod & po \tn % Row Count 11 (+ 1) % Row 10 \SetRowColor{LightBackground} \seqsplit{replicationController} & rc \tn % Row Count 13 (+ 2) % Row 11 \SetRowColor{white} service & svc \tn % Row Count 14 (+ 1) % Row 12 \SetRowColor{LightBackground} \seqsplit{persistentVolume} & pv \tn % Row Count 15 (+ 1) % Row 13 \SetRowColor{white} \seqsplit{persistentVolumeClaim} & pvc \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}