Add an application to the ML platform
In the ML platform, you can add additional applications using kubectl, helm, kustomize.
You can open the app via a URL like https://myapp-yourdomain.mlops.selcloud.ru or add the app to the ML platform start page.
For applications that will be available online, you need to set up authorization.
Add a new application to the ML platform
To add a new application to the ML platform, you need to create an Ingress object. You do not need to create an Ingress Controller - a Traefik controller is pre-installed in the ML-platform in Managed Kubernetes clusters.
It is not necessary to obtain TLS certificates directly in the ML platform because the certificate is installed on the reverse proxy.
-
Connect to the Managed Kubernetes cluster that was created when ML platform.
-
Create a yaml file with a manifest for the Ingress object.
Manifesto example:
apiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: myappnamespace: <ml_platform_namespace>annotations:traefik.ingress.kubernetes.io/router.tls: "true"spec:tls:- hosts:- "myapp-<ml_platform_domain>"secretName: myapp-<ml_platform_domain>-certrules:- host: "myapp-<ml_platform_domain>"http:paths:- path: /pathType: Prefixbackend:service:name: myappport:number: 80Specify:
<ml_platform_namespace>- Namespace of the ML platform;<ml_platform_domain>- URL of the formyourdomain.mlops.selcloud.ruwhich was given after connecting ML-platform.
-
Create Ingress:
kubectl apply -f <ingress.yaml>Specify
<ingress.yaml>is the name of the yaml file with the manifest for Ingress. -
Open the application at:
https://myapp-<ml_platform_domain>Specify
<ml_platform_domain>- URL of the formyourdomain.mlops.selcloud.ru, which was issued after connecting ML-platform. -
Optional: add the app to your start page.
Add an application to the ML-platform start page
The ML platform start page is powered by the Forecastle tool. On the page you can see all the applications that are running in the Managed Kubernetes cluster by default.
If you've added a new app to the ML platform, it can also be placed on the home page.
-
Connect to the Managed Kubernetes cluster that was created when ML platform.
-
Open the yaml file with the manifest for the Ingress application and add annotations to it:
apiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: myappnamespace: <ml_platform_namespace>annotations:traefik.ingress.kubernetes.io/router.tls: "true"forecastle.stakater.com/expose: "true"forecastle.stakater.com/appName: MyApp # App name shown on the start pageforecastle.stakater.com/group: MyAppsGroup # Group on the start page where the app will be addedforecastle.stakater.com/icon: <app_icon_url>Specify:
<ml_platform_namespace>- Namespace of the ML platform;<app_icon_url>- optional: URL of the image for the app icon.
-
Apply the changes for Ingress:
kubectl apply -f <ingress.yaml>Specify
<ingress.yaml>is the name of the yaml file with the manifest for Ingress. -
Open the ML platform start page and check that the app has been added:
https://myapp-<ml_platform_domain>Specify
<ml_platform_domain>- URL of the formyourdomain.mlops.selcloud.ru, which was issued after connecting ML-platform.
Configure authorization for the application
If you've added an application to the ML platform, be sure to set up authorization.
The authorization setting depends on the protocols that the application supports:
- If the application supports authorization using OIDC/OAuth2/SAML protocols, create a Keycloak client;
- If the application does not support OIDC/OAuth2/SAML protocols or the application does not have authorization mechanisms, use gogatekeeper - it is a sidecar for Keycloak.
Authorization with OIDC
Authorization with gogatekeeper
Create a Keycloak client and configure the application to authorize through the Keycloak ML platform. When the user authorizes in the application, a request will be sent to the Keycloak client. If it fails it, the user will be able to log into the app. For more information about using Keycloak in ML-platform, see the Managing Users in Keycloak instructions.
-
Connect to the Managed Kubernetes cluster that was created when ML platform.
-
Create a Keycloak client through the Keycloak control panel at
https://keycloak-<ml_platform_domain>/admin/cmlp/console/or create a yaml file with a manifest for the KeycloakClient object.Manifesto example:
apiVersion: keycloak.org/v1alpha1kind: KeycloakClientmetadata:name: myapp-clientnamespace: <ml_platform_namespace>spec:client:# Settingsenabled: trueclientId: "<appclient_name>"name: ""description: ''secret: "<password>"protocol: "openid-connect"redirectUris:- "https://<appclient_name>-.<ml_platform_namespace>/*" # URI from which redirect to Keycloak occursrootUrl: "${authBaseUrl}"baseUrl: "/"publicClient: falsebearerOnly: falseserviceAccountsEnabled: falseconsentRequired: falsedirectAccessGrantsEnabled: trueimplicitFlowEnabled: falsefrontchannelLogout: falsestandardFlowEnabled: truesurrogateAuthRequired: falseuseTemplateConfig: trueuseTemplateMappers: true# ScopesuseTemplateScope: truefullScopeAllowed: falsedefaultClientScopes:- "profile"- "email"# RolesprotocolMappers:- config:access.token.claim: "true"id.token.claim: "false"included.custom.audience: <appclient_name>consentRequired: falsename: Audience-forecastle-cmlpprotocol: openid-connectprotocolMapper: oidc-audience-mapperrealmSelector:matchLabels:app.kubernetes.io/name: keycloak-realm-cmlpapp.kubernetes.io/instance: keycloak-operatorSpecify:
<ml_platform_namespace>- Namespace of the ML platform;<appclient_name>- The unique name of the Keycloak client;<password>- password for the Keycloak client. Required to configure the application.
-
Create a Keycloak client:
kubectl apply -f <keycloakclient.yaml>Specify
<keycloakclient.yaml>is the name of the manifest yaml file to create the Keycloak client. -
Verify that the client has been created: open the Security Admin Console application and go to Configure → Clients.
-
Configure the application to authorize through the created Keycloak client:
- use the python library python-keycloak;
- or use Grafana and modify the configuration file following the example in the Grafana documentation.