Add an application to the ML platform
In the ML platform, you can add additional applications using kubectl, helm, or kustomize.
You can open the application using a URL like https://myapp-yourdomain.mlops.selcloud.ru or add the application to the ML platform home page.
For applications that will be accessible on the internet, you must configure authorization.
Add a new application to the ML platform
To add a new application to the ML platform, you need to create an object of type Ingress. You do not need to create an Ingress Controller—the Traefik controller is preinstalled in ML platform Managed Kubernetes clusters.
There is no need to obtain TLS certificates directly in the ML platform, as the certificate is installed on the reverse proxy.
-
Connect to the Managed Kubernetes cluster that was created when connecting the ML platform.
-
Create a yaml file with a manifest for the Ingress object.
Example manifest:
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>— ML platform Namespace (Namespace);<ml_platform_domain>— a URL likeyourdomain.mlops.selcloud.ru, which was issued after connecting the ML platform.
-
Create an Ingress:
kubectl apply -f <ingress.yaml>Specify
<ingress.yaml>— the name of the yaml file with the Ingress manifest. -
Open the application at the address:
https://myapp-<ml_platform_domain>Specify
<ml_platform_domain>— a URL likeyourdomain.mlops.selcloud.ru, which was issued after connecting the ML platform. -
Optional: add the application to the home page.
Add an application to the ML platform home page
The ML platform home page works using the Forecastle tool. You can view all applications that are running by default in the Managed Kubernetes cluster on this page.
If you have added a new application to the ML platform, you can also place it on the home page.
-
Connect to the Managed Kubernetes cluster that was created when connecting the ML platform.
-
Open the yaml file with the manifest for the application Ingress 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>— ML platform Namespace (Namespace);<app_icon_url>— optional: URL for the application icon.
-
Apply the changes for the Ingress:
kubectl apply -f <ingress.yaml>Specify
<ingress.yaml>— the name of the yaml file with the Ingress manifest. -
Open the ML platform home page and verify that the application has been added:
https://myapp-<ml_platform_domain>Specify
<ml_platform_domain>— a URL likeyourdomain.mlops.selcloud.ru, which was issued after connecting the ML platform.
Configure authorization for the application
If you have added an application to the ML platform, be sure to configure authorization.
Authorization setup depends on the protocols supported by the application:
- 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 has no authorization mechanisms, use gogatekeeper—this is a sidecar for Keycloak.
Authorization using OIDC
Authorization using gogatekeeper
Create a Keycloak client and configure authorization for the application via the ML platform's Keycloak. When a user authorizes in the application, a request is sent to the Keycloak client. If validated, the user can access the application. Learn more about using Keycloak in the ML platform in the Managing users in Keycloak guide.
-
Connect to the Managed Kubernetes cluster that was created when connecting the ML platform.
-
Create a Keycloak client via the Keycloak control panel at
https://keycloak-<ml_platform_domain>/admin/cmlp/console/or create a yaml file with a manifest for a KeycloakClient object.Example manifest:
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>— ML platform Namespace (Namespace);<appclient_name>— a unique name for the Keycloak client;<password>— password for the Keycloak client. Required for application configuration.
-
Create a Keycloak client:
kubectl apply -f <keycloakclient.yaml>Specify
<keycloakclient.yaml>— the name of the yaml file with the manifest 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 for authorization via the created Keycloak client:
- use the python-library python-keycloak;
- or use Grafana and modify the configuration file following the example from the Grafana documentation.