2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
.. oiz1581955060428
|
|
|
|
.. _configure-remote-helm-client-for-non-admin-users:
|
|
|
|
|
2021-03-30 12:01:56 -03:00
|
|
|
===============================
|
|
|
|
Configure Remote Helm v2 Client
|
|
|
|
===============================
|
2020-08-31 11:01:56 -04:00
|
|
|
|
2021-03-30 12:01:56 -03:00
|
|
|
Helm v3 is recommended for users to install and manage their
|
|
|
|
containerized applications. However, Helm v2 may be required, for example, if
|
2021-06-04 17:57:46 -03:00
|
|
|
the containerized application supports only a Helm v2 chart.
|
2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
.. rubric:: |context|
|
|
|
|
|
2021-03-30 12:01:56 -03:00
|
|
|
Helm v2 is only supported remotely. Also, it is only supported with kubectl and
|
|
|
|
Helm v2 clients configured directly on the remote host workstation. In
|
|
|
|
addition to installing the Helm v2 clients, users must also create their own
|
|
|
|
Tiller server, in a namespace that the user has access, with the required |RBAC|
|
2020-08-31 11:01:56 -04:00
|
|
|
capabilities and optionally |TLS| protection.
|
|
|
|
|
2021-03-30 12:01:56 -03:00
|
|
|
Complete the following steps to configure Helm v2 for managing containerized
|
2021-06-04 17:57:46 -03:00
|
|
|
applications with a Helm v2 chart.
|
2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
.. rubric:: |proc|
|
|
|
|
|
|
|
|
.. _configure-remote-helm-client-for-non-admin-users-steps-isx-dsd-tkb:
|
|
|
|
|
2021-03-30 12:01:56 -03:00
|
|
|
#. On the controller, create an admin-user service account if this is not
|
|
|
|
already available.
|
|
|
|
|
|
|
|
#. Create the **admin-user** service account in **kube-system**
|
|
|
|
namespace and bind the **cluster-admin** ClusterRoleBinding to this user.
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
% cat <<EOF > admin-login.yaml
|
|
|
|
apiVersion: v1
|
|
|
|
kind: ServiceAccount
|
|
|
|
metadata:
|
|
|
|
name: admin-user
|
|
|
|
namespace: kube-system
|
|
|
|
---
|
2022-12-19 12:18:24 -05:00
|
|
|
apiVersion: v1
|
|
|
|
kind: Secret
|
|
|
|
type: kubernetes.io/service-account-token
|
|
|
|
metadata:
|
|
|
|
name: admin-user-sa-token
|
|
|
|
namespace: kube-system
|
|
|
|
annotations:
|
|
|
|
kubernetes.io/service-account.name: admin-user
|
|
|
|
---
|
2021-03-30 12:01:56 -03:00
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: ClusterRoleBinding
|
|
|
|
metadata:
|
|
|
|
name: admin-user
|
|
|
|
roleRef:
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
kind: ClusterRole
|
|
|
|
name: cluster-admin
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: admin-user
|
|
|
|
namespace: kube-system
|
|
|
|
EOF
|
|
|
|
% kubectl apply -f admin-login.yaml
|
|
|
|
|
|
|
|
#. Retrieve the secret token.
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
% kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
|
|
|
|
|
|
|
|
|
|
|
|
#. On the workstation, if it is not available, install the :command:`kubectl` client on an Ubuntu
|
|
|
|
host by taking the following actions on the remote Ubuntu system.
|
|
|
|
|
|
|
|
#. Install the :command:`kubectl` client CLI.
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
% sudo apt-get update
|
|
|
|
% sudo apt-get install -y apt-transport-https
|
|
|
|
% curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
|
|
|
|
sudo apt-key add
|
|
|
|
% echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | \
|
|
|
|
sudo tee -a /etc/apt/sources.list.d/kubernetes.list
|
|
|
|
% sudo apt-get update
|
|
|
|
% sudo apt-get install -y kubectl
|
|
|
|
|
|
|
|
#. Set up the local configuration and context.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
In order for your remote host to trust the certificate used by
|
|
|
|
the |prod-long| K8S API, you must ensure that the
|
|
|
|
**k8s\_root\_ca\_cert** specified at install time is a trusted
|
|
|
|
CA certificate by your host. Follow the instructions for adding
|
|
|
|
a trusted CA certificate for the operating system distribution
|
|
|
|
of your particular host.
|
|
|
|
|
|
|
|
If you did not specify a **k8s\_root\_ca\_cert** at install
|
2021-06-04 17:57:46 -03:00
|
|
|
time, then specify ``--insecure-skip-tls-verify``, as shown below.
|
2021-03-30 12:01:56 -03:00
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
% kubectl config set-cluster mycluster --server=https://<oam-floating-IP>:6443 \
|
|
|
|
--insecure-skip-tls-verify
|
|
|
|
% kubectl config set-credentials admin-user@mycluster --token=$TOKEN_DATA
|
|
|
|
% kubectl config set-context admin-user@mycluster --cluster=mycluster \
|
|
|
|
--user admin-user@mycluster --namespace=default
|
|
|
|
% kubectl config use-context admin-user@mycluster
|
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
``$TOKEN_DATA`` is the token retrieved in step 1.
|
2021-03-30 12:01:56 -03:00
|
|
|
|
|
|
|
#. Test remote :command:`kubectl` access.
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
% kubectl get nodes -o wide
|
2022-12-15 15:07:56 -05:00
|
|
|
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
|
|
|
|
compute-0 Ready <none> 9d v1.24.4 192.168.204.69 <none> Debian GNU/Linux 11 (bullseye) 5.10.0-6-amd64 containerd://1.4.12
|
|
|
|
compute-1 Ready <none> 9d v1.24.4 192.168.204.7 <none> Debian GNU/Linux 11 (bullseye) 5.10.0-6-amd64 containerd://1.4.12
|
|
|
|
controller-0 Ready control-plane,master 9d v1.24.4 192.168.204.3 <none> Debian GNU/Linux 11 (bullseye) 5.10.0-6-amd64 containerd://1.4.12
|
|
|
|
controller-1 Ready control-plane,master 9d v1.24.4 192.168.204.4 <none> Debian GNU/Linux 11 (bullseye) 5.10.0-6-amd64 containerd://1.4.12
|
2021-03-30 12:01:56 -03:00
|
|
|
%
|
|
|
|
|
|
|
|
#. Install the Helm v2 client on remote workstation.
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
% wget https://get.helm.sh/helm-v2.13.1-linux-amd64.tar.gz
|
|
|
|
% tar xvf helm-v2.13.1-linux-amd64.tar.gz
|
|
|
|
% sudo cp linux-amd64/helm /usr/local/bin
|
|
|
|
|
|
|
|
Verify that :command:`helm` is installed correctly.
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
% helm version
|
|
|
|
Client: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}
|
2021-06-04 17:57:46 -03:00
|
|
|
|
2021-03-30 12:01:56 -03:00
|
|
|
Server: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}
|
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
#. On the workstation, set the namespace for which you want Helm v2 access to.
|
2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
2021-03-15 16:56:04 -03:00
|
|
|
~(keystone_admin)]$ NAMESPACE=default
|
2020-08-31 11:01:56 -04:00
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
#. On the workstation, set up accounts, roles and bindings for Tiller (Helm v2 cluster access).
|
2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
#. Execute the following commands.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
These commands could be run remotely by the non-admin user who
|
|
|
|
has access to the default namespace.
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
2021-03-15 16:56:04 -03:00
|
|
|
~(keystone_admin)]$ cat <<EOF > default-tiller-sa.yaml
|
2020-08-31 11:01:56 -04:00
|
|
|
apiVersion: v1
|
|
|
|
kind: ServiceAccount
|
|
|
|
metadata:
|
|
|
|
name: tiller
|
|
|
|
namespace: default
|
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: Role
|
|
|
|
metadata:
|
|
|
|
name: tiller
|
|
|
|
namespace: default
|
|
|
|
rules:
|
|
|
|
- apiGroups: ["*"]
|
|
|
|
resources: ["*"]
|
|
|
|
verbs: ["*"]
|
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: RoleBinding
|
|
|
|
metadata:
|
|
|
|
name: tiller
|
|
|
|
namespace: default
|
|
|
|
roleRef:
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
kind: Role
|
|
|
|
name: tiller
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: tiller
|
|
|
|
namespace: default
|
|
|
|
EOF
|
2021-03-15 16:56:04 -03:00
|
|
|
~(keystone_admin)]$ kubectl apply -f default-tiller-sa.yaml
|
2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
#. Execute the following commands as an admin-level user.
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
~(keystone_admin)]$ kubectl create clusterrole tiller --verb get --resource namespaces
|
|
|
|
~(keystone_admin)]$ kubectl create clusterrolebinding tiller --clusterrole tiller --serviceaccount ${NAMESPACE}:tiller
|
2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
#. On the workstation, initialize Helm v2 access with :command:`helm init`
|
|
|
|
command to start Tiller in the specified NAMESPACE with the specified RBAC
|
|
|
|
credentials.
|
2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
~(keystone_admin)]$ helm init --service-account=tiller --tiller-namespace=$NAMESPACE --output yaml | sed 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' | sed 's@ replicas: 1@ replicas: 1\n \ selector: {"matchLabels": {"app": "helm", "name": "tiller"}}@' > helm-init.yaml
|
2021-03-15 16:56:04 -03:00
|
|
|
~(keystone_admin)]$ kubectl apply -f helm-init.yaml
|
2021-06-04 17:57:46 -03:00
|
|
|
~(keystone_admin)]$ helm init --client-only --stable-repo-url https://charts.helm.sh/stable
|
2020-08-31 11:01:56 -04:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
Ensure that each of the patterns between single quotes in the above
|
|
|
|
:command:`sed` commands are on single lines when run from your
|
|
|
|
command-line interface.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
Add the following options if you are enabling TLS for this Tiller:
|
|
|
|
|
|
|
|
``--tiller-tls``
|
|
|
|
Enable TLS on Tiller.
|
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
``--tiller-tls-cert <certificate_file>``
|
2020-08-31 11:01:56 -04:00
|
|
|
The public key/certificate for Tiller \(signed by ``--tls-ca-cert``\).
|
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
``--tiller-tls-key <key_file>``
|
2020-08-31 11:01:56 -04:00
|
|
|
The private key for Tiller.
|
|
|
|
|
|
|
|
``--tiller-tls-verify``
|
|
|
|
Enable authentication of client certificates \(i.e. validate
|
|
|
|
they are signed by ``--tls-ca-cert``\).
|
|
|
|
|
2021-06-04 17:57:46 -03:00
|
|
|
``--tls-ca-cert <certificate_file>``
|
2020-08-31 11:01:56 -04:00
|
|
|
The public certificate of the |CA| used for signing Tiller
|
|
|
|
server and helm client certificates.
|
|
|
|
|
|
|
|
.. rubric:: |result|
|
|
|
|
|
2021-03-30 12:01:56 -03:00
|
|
|
You can now use the private Tiller server remotely by specifying
|
2020-08-31 11:01:56 -04:00
|
|
|
the ``--tiller-namespace`` default option on all helm CLI commands. For
|
|
|
|
example:
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
|
|
helm version --tiller-namespace default
|
|
|
|
helm install --name wordpress stable/wordpress --tiller-namespace default
|
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
:ref:`Configure Container-backed Remote CLIs and Clients
|
|
|
|
<security-configure-container-backed-remote-clis-and-clients>`
|
|
|
|
|
2021-03-15 16:56:04 -03:00
|
|
|
:ref:`Using Container-backed Remote CLIs and Clients
|
|
|
|
<using-container-backed-remote-clis-and-clients>`
|
|
|
|
|
2020-08-31 11:01:56 -04:00
|
|
|
:ref:`Install Kubectl and Helm Clients Directly on a Host
|
|
|
|
<security-install-kubectl-and-helm-clients-directly-on-a-host>`
|
|
|
|
|