Said
09/25/2024, 7:19 AMMarvin
09/25/2024, 7:19 AMpip install -U prefect
2. Configure Prefect Server:
Prefect 2.x documentation does not clearly specify basic authentication. However, you can connect to Prefect Cloud with a basic login:
prefect cloud login
This allows interactive login with an API key or web browser.
3. Manage Authentication via CLI:
You might need an API key if you're working with Prefect Cloud:
prefect cloud login -k '<my-api-key>'
4. Additional Resources:
For further details, refer to these links:
- Connecting to Prefect Cloud
- Prefect Databricks Credentials
### Prefect 3.x:
1. Install Prefect:
pip install -U prefect
2. API Key Authentication:
You can create an API key to authenticate your local environment with Prefect Cloud:
- Go to the account icon in Prefect Cloud UI.
- Select "API Keys" and generate a new key.
3. Login Command:
Use the following CLI command to login with your API key:
prefect cloud login -k '<my-api-key>'
4. SSO Configuration:
Prefect Cloud Enterprise offers SSO (Single Sign-On) integration with identity providers supporting OIDC or SAML 2.0:
- Enable SSO for your domain in the Prefect Cloud UI.
- Configure it using the identity provider's dashboard.
5. Additional Resources:
- Connecting to Prefect Cloud
- Manage API Keys
- Configure SSO
For setting up basic authentication on Prefect OSS specifically, you may need to look into configuring your infrastructure (e.g., using reverse proxies like Nginx or Traefik that support basic auth) as the provided Prefect setups do not natively support basic auth configurations directly.Said
09/25/2024, 7:51 AMMarvin
09/25/2024, 7:52 AMbash
helm repo add ingress-nginx <https://kubernetes.github.io/ingress-nginx>
helm repo update
helm install nginx-ingress ingress-nginx/ingress-nginx --namespace ingress-nginx --create-namespace
2. Create a Secret for Basic Auth:
Generate a password file using htpasswd
(you might need to install apache2-utils
package if it's not available):
bash
htpasswd -c auth myuser
This will prompt you to enter a password for "myuser". Once done, create a Kubernetes secret from this file:
bash
kubectl create secret generic basic-auth --from-file=auth -n your-namespace
3. Create an Ingress Resource:
Define an Ingress resource with the basic authentication annotation:
yaml
apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: Ingress
metadata:
name: prefect-server-ingress
namespace: your-namespace
annotations:
<http://nginx.ingress.kubernetes.io/auth-type|nginx.ingress.kubernetes.io/auth-type>: "basic"
<http://nginx.ingress.kubernetes.io/auth-secret|nginx.ingress.kubernetes.io/auth-secret>: "basic-auth"
<http://nginx.ingress.kubernetes.io/auth-realm|nginx.ingress.kubernetes.io/auth-realm>: "Authentication Required"
spec:
rules:
- host: <your-domain>
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: prefect-server
port:
number: 80
Replace <your-domain>
with your domain and adjust the service name and port according to your Prefect Server deployment.
4. Deploy Ingress Resource:
Apply the Ingress resource:
bash
kubectl apply -f ingress-resource.yaml
### Using Traefik Ingress Controller
1. Install Traefik:
Install Traefik in your Kubernetes cluster using Helm:
bash
helm repo add traefik <https://helm.traefik.io/traefik>
helm repo update
helm install traefik traefik/traefik --namespace kube-system
2. Create a Secret for Basic Auth:
Similar to the above steps, generate a password file and create a secret:
bash
htpasswd -c auth myuser
kubectl create secret generic basic-auth --from-file=auth -n your-namespace
3. Create an IngressRoute Resource:
Define an IngressRoute resource for Traefik:
yaml
apiVersion: <http://traefik.containo.us/v1alpha1|traefik.containo.us/v1alpha1>
kind: IngressRoute
metadata:
name: prefect-server-ingress
namespace: your-namespace
spec:
entryPoints:
- web
routes:
- match: Host(`<your-domain>`)
kind: Rule
services:
- name: prefect-server
port: 80
middlewares:
- name: authmiddleware
---
apiVersion: <http://traefik.containo.us/v1alpha1|traefik.containo.us/v1alpha1>
kind: Middleware
metadata:
name: authmiddleware
namespace: your-namespace
spec:
basicAuth:
secret: basic-auth
Replace <your-domain>
with your domain and adjust the service name and port according to your Prefect Server deployment.
4. Deploy IngressRoute Resource:
Apply the IngressRoute resource:
bash
kubectl apply -f ingressroute-resource.yaml
### References
- Prefect Kubernetes Deployment Guide
- Deploy Prefect Worker using HelmMarvin
09/25/2024, 7:52 AMSaid
09/25/2024, 10:46 AMMarvin
09/25/2024, 10:46 AM