docs/doc/source/usertasks/usertask-using-container-backed-remote-clis-and-clients.rst
Stone f63f0912c6 User Tasks guide
Fixed typo in LetsEncrypt example

Removed duplicate Datanet entry from main index.rst

Reworked Use Kubernetes CPU Manager Static Policy prerequisite block.

Restored fault/index version of FM toctree in top-level index.

Added merged doc entries to top level index.rst.

Incorporated review comments. Also some generic formatting clean-up such as
converting abbreviations to rST-style :abbr: markup.

Moved url with embedded substitution out of code-block.

Addressed patch 2 review comments. Some addtional rST tidying. See comment replies
for open questions/issues.

This patch fixes an issue with 'stx' in filenames that may differ downstream using-an-image-from-the-local-docker-registry-in-a-container-spec
new substitution and changing code-blocks to parsed-literals as required.

Initial submission for review. Note that a couple of references to WR persist
in examples. These will be marked up with comments in the review.

Signed-off-by: Stone <ronald.stone@windriver.com>
Change-Id: I1efef569842caff5def9dc00395b594d91d7a5d0
Signed-off-by: Stone <ronald.stone@windriver.com>
2020-12-02 10:34:53 -05:00

5.4 KiB

Use Container-backed Remote CLIs

Remote platform CLIs (Command Line Interfaces) can be used in any shell after sourcing the generated remote CLI/client RC file. This RC file sets up the required environment variables and aliases for the remote CLI commands.

The following topics are discussed below:

Note

Consider adding this command to your .login or shell rc file, such that your shells will automatically be initialized with the environment variables and aliases for the remote CLI commands.

You must have completed the configuration steps described in Configuring Container-backed Remote CLIs <kubernetes-user-tutorials-configuring-container-backed-remote-clis-and-clients> before proceeding.

Kubernetes kubectl CLI commands

Note

The first usage of a remote CLI command will be slow as it requires that the docker image supporting the remote CLIs/clients be pulled from the remote registry.

root@myclient:/home/user/remote_wd# source remote_client_platform.sh
Please enter your OpenStack Password for project tenant1 as user user1:

root@myclient:/home/user/remote_wd# kubectl -n kube-system get pods
NAME                                       READY   STATUS      RESTARTS   AGE
calico-kube-controllers-767467f9cf-wtvmr   1/1     Running     1          3d2h
calico-node-j544l                          1/1     Running     1          3d
calico-node-ngmxt                          1/1     Running     1          3d1h
calico-node-qtc99                          1/1     Running     1          3d
calico-node-x7btl                          1/1     Running     4          3d2h
ceph-pools-audit-1569848400-rrpjq          0/1     Completed   0          12m
ceph-pools-audit-1569848700-jhv5n          0/1     Completed   0          7m26s
ceph-pools-audit-1569849000-cb988          0/1     Completed   0          2m25s
coredns-7cf476b5c8-5x724                   1/1     Running     1          3d2h
...
root@myclient:/home/user/remote_wd#

Note

Some CLI commands are designed to leave you in a shell prompt, for example:

root@myclient:/home/user/remote_wd# openstack

or

root@myclient:/home/user/remote_wd# kubectl exec -ti <pod_name> -- /bin/bash

In most cases, the remote CLI will detect and handle these commands correctly. If you encounter cases that are not handled correctly, you can force-enable or disable the shell options using the <FORCE_SHELL> or <FORCE_NO_SHELL> variables before the command.

For example:

root@myclient:/home/user/remote_wd# FORCE_SHELL=true kubectl exec -ti <pod_name> -- /bin/bash
root@myclient:/home/user/remote_wd# FORCE_NO_SHELL=true kubectl exec <pod_name> -- ls

You cannot use both variables at the same time.

Remote CLI commands with local files

If you need to run a remote CLI command that references a local file, then that file must be copied to or created in the working directory specified in the -w option on the ./config_client.sh command.

For example:

  1. If you have not already done so, source the remote_client_platform.sh file.

    root@myclient:/home/user/remote_wd# source remote_client_platform.sh
  2. Copy the file local file and run the remote command.

    root@myclient:/home/user# cp /<someDir>/test.yml $HOME/remote_cli_wd/test.yml
    root@myclient:/home/user# cd $HOME/remote_cli_wd
    root@myclient:/home/user/remote_cli_wd# kubectl -n kube-system  create -f test.yml
    pod/test-pod created
    root@myclient:/home/user/remote_cli_wd# kubectl -n kube-system  delete -f test.yml
    pod/test-pod deleted

Helm

Do the following to use helm.

Note

When using helm, any command that requires access to a helm repository (managed locally) will require that you be in the $HOME/remote_cli_wd directory and use the --home "./.helm" option.

  1. Do the initial set-up of the helm client.
    1. If you have not already done so, source the remote_client_platform.sh file.

      % source remote_client_platform.sh
    2. Complete the initial set-up.

      % cd $HOME/remote_cli_wd
      % helm init --client-only --home "./.helm"
  2. Run a helm command.
    1. If you have not already done so, source the remote_client_platform.sh file.

      % source remote_client_platform.sh
    2. Run a helm command. This example installs WordPress.

      % cd $HOME/remote_cli_wd
      % helm list
      % helm install --name wordpress stable/wordpress  --home "./.helm"