Add Extra Resources To All User Namespaces¶
In Arrikto EKF the Profile Controller takes care of deploying some Kubernetes resources under each user namespace by default. Those resources allow users to access Rok and Kubeflow Pipelines.
This section describes how to configure your Arrikto EKF installation to add
extra, user-specified Kubernetes resources to all user namespaces. It makes
use of the skel-resources
deploy
overlay.
What You’ll Need¶
- A configured management environment.
- Your clone of the Arrikto GitOps repository.
Procedure¶
Switch to the
kubeflow/manifests
directory of your GitOps repository:root@rok-tools:~# cd ~/ops/deployments/kubeflow/manifestsAdd any additional files with your resources under
common/skel-resources/overlays/deploy
. For instance, to add an example PodDefault resource, save the following file ascommon/skel-resources/overlays/deploy/poddefault-example.yaml
:apiVersion: kubeflow.org/v1alpha1 kind: PodDefault metadata: name: example-extra-resource spec: desc: Example extra PodDefault resource env: - name: EXAMPLE_ENVVAR value: example selector: matchLabels: example-extra-resource: "true"Note
The resources can include template variables in the Go template format. The Profile Controller renders the templated resources before applying them to user namespaces. For example, to add a resource that includes an annotation with the user namespace without the
kubeflow-
prefix, insert the following in your resource:annotations: example.annotation: '{{ .Namespace|trimPrefix "kubeflow-" }}'In the above example:
.Namespace
is the template variable, andtrimPrefix
is the function that modifies the value of the variable.
You can check more supported functions at the Sprig Go library.
Supported variables are:
.Namespace
: The user namespace where the Profile Controller applies the resource.
Modify the
common/skel-resources/overlays/deploy/kustomization.yaml
file to include the files with your resources. For example:resources: - ../../base - poddefault-example.yaml # <-- Add this line with your actual file nameNote
Add as many extra lines as needed to include all the files you have created.
Detect the resource type of your extra resources, in the
<name>.<api-group>
format, where:<name>
: The lowercase, plural version of thekind
field.<api-group>
: The part of theapiVersion
field before the first slash (/
).
For instance, for the following example PodDefault resource, the desired resource type is
poddefaults.kubeflow.org
:apiVersion: kubeflow.org/v1alpha1 kind: PodDefault metadata: name: example-extra-resource ...Edit
apps/profiles/upstream/overlays/deploy/patches/configmap.yaml
to update the list of resource types the Profile Controller manages:data: ... # <-- Update following line with the types of resources to manage --> SKEL_RESOURCES: secrets,configmaps,serviceaccounts,rolebindings.rbac.authorization.k8s.io,poddefaults.kubeflow.org,roksnapshotpolicies.crd.arrikto.com,rokpresentationpolicies.crd.arrikto.com ...Note
The Profile Controller manages resources of the following types by default:
secrets
configmaps
serviceaccounts
rolebindings.rbac.authorization.k8s.io
poddefaults.kubeflow.org
roksnapshotpolicies.crd.arrikto.com
rokpresentationpolicies.crd.arrikto.com
Skip this step if the above list includes the types of all your extra resources.
Make sure that the above patch is enabled. Edit
apps/profiles/upstream/overlays/deploy/kustomization.yaml
and addpatches/configmap.yaml
underpatches
, if it doesn’t exist already:patches: - patches/configmap.yaml # <-- Add this lineCommit your changes:
root@rok-tools:~/ops/deployments/kubeflow/manifests# git commit -am "Add extra skel resources"Apply the kustomization:
root@rok-tools:~/ops/deployments/kubeflow/manifests# rok-deploy --apply \ > common/skel-resources/overlays/deploy \ > apps/profiles/upstream/overlays/deploy
Verify¶
Check that the
kubeflow-skel
namespace has the extra resources:root@rok-tools:~# kubectl get -n kubeflow-skel <RESOURCE_TYPE>Replace
RESOURCE_TYPE
with the type of the extra resource you added, for example:root@rok-tools:~# kubectl get -n kubeflow-skel poddefaults.kubeflow.org NAME AGE kale-python-image 19d access-ml-pipeline 19d rok-auth 19d example-extra-resource 10d
Note
Repeat the following steps for every namespace that you wish to verify.
Specify the namespace that you want to verify:
root@rok-tools:~# export NAMESPACE=<NAMESPACE>Replace
NAMESPACE
with the name of the namespace that you wish to verify, for example:root@rok-tools:~# export NAMESPACE=kubeflow-userCheck that the namespace has the extra resources:
root@rok-tools:~# kubectl get -n ${NAMESPACE?} <RESOURCE_TYPE>Replace
RESOURCE_TYPE
with the type of the extra resource you added, for example:root@rok-tools:~# kubectl get -n ${NAMESPACE?} poddefaults.kubeflow.org NAME AGE kale-python-image 19d access-ml-pipeline 19d rok-auth 19d example-extra-resource 10d
Summary¶
You have successfully added extra resources to all user namespaces.