diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2d26a7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# General +.DS_Store +.AppleDouble +.LSOverride + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Emacs save files +*~ +\#*\# +.\#* + +# Vim-related files +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist + +# Environments +#.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +#.idea/ +*.log +.idea +.DS_store +*.pyc +*.iml + +# VS Code +.vscode diff --git a/charts/feathr-online-sandbox/.DS_Store b/charts/feathr-online-sandbox/.DS_Store new file mode 100644 index 0000000..a78fef0 Binary files /dev/null and b/charts/feathr-online-sandbox/.DS_Store differ diff --git a/charts/feathr-online-sandbox/Chart.yaml b/charts/feathr-online-sandbox/Chart.yaml new file mode 100644 index 0000000..63aa5d4 --- /dev/null +++ b/charts/feathr-online-sandbox/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: feathr-online +description: A Helm chart for Feathr Online Server + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.2 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "" diff --git a/charts/feathr-online-sandbox/README.md b/charts/feathr-online-sandbox/README.md new file mode 100644 index 0000000..01d7b15 --- /dev/null +++ b/charts/feathr-online-sandbox/README.md @@ -0,0 +1,29 @@ +# feathr-online + +![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) + +A Helm chart for Feathr Online Server + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| fullnameOverride | string | `""` | | +| image.pullPolicy | string | `"Always"` | | +| image.repository | string | `"windoze/feathrpiper"` | | +| image.tag | string | `"latest"` | | +| imagePullSecrets | list | `[]` | | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| podAnnotations | object | `{}` | | +| podSecurityContext | object | `{}` | | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.port | int | `80` | | +| service.type | string | `"ClusterIP"` | | +| tolerations | list | `[]` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/charts/feathr-online-sandbox/templates/NOTES.txt b/charts/feathr-online-sandbox/templates/NOTES.txt new file mode 100644 index 0000000..65a258b --- /dev/null +++ b/charts/feathr-online-sandbox/templates/NOTES.txt @@ -0,0 +1,34 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "feathr-online.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "feathr-online.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "feathr-online.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "feathr-online.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +2. To test the application, run the following command: +curl -s -H"content-type:application/json" http://127.0.0.1:8080/process -d'{ + "requests": [ + { + "pipeline": "nyc_taxi_demo_3_local_compute", + "data": { + "pu_loc_id": 41, + "do_loc_id": 57, + "pu_time": "2020/4/1 0:41", + "do_time": "2020/4/1 0:56", + "trip_distance": 6.79, + "fare_amount": 21.0 + } + } + ] +}' +You might need to replace 127.0.0.1:8080 with the application URL from step 1. You should see the following output if everything setups well: +{"results":[{"pipeline":"nyc_taxi_demo_3_local_compute",...}}]} \ No newline at end of file diff --git a/charts/feathr-online-sandbox/templates/_helpers.tpl b/charts/feathr-online-sandbox/templates/_helpers.tpl new file mode 100644 index 0000000..f9ae466 --- /dev/null +++ b/charts/feathr-online-sandbox/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "feathr-online.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "feathr-online.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "feathr-online.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "feathr-online.labels" -}} +helm.sh/chart: {{ include "feathr-online.chart" . }} +{{ include "feathr-online.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "feathr-online.selectorLabels" -}} +app.kubernetes.io/name: {{ include "feathr-online.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/feathr-online-sandbox/templates/deployment.yaml b/charts/feathr-online-sandbox/templates/deployment.yaml new file mode 100644 index 0000000..06a7ed5 --- /dev/null +++ b/charts/feathr-online-sandbox/templates/deployment.yaml @@ -0,0 +1,58 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "feathr-online.fullname" . }} + labels: + {{- include "feathr-online.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "feathr-online.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "feathr-online.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8000 + protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: 8000 + readinessProbe: + httpGet: + path: /healthz + port: 8000 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/feathr-online-sandbox/templates/redis.yaml b/charts/feathr-online-sandbox/templates/redis.yaml new file mode 100644 index 0000000..efcf34c --- /dev/null +++ b/charts/feathr-online-sandbox/templates/redis.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "feathr-online.fullname" . }}-redis + labels: + {{- include "feathr-online.labels" . | nindent 4 }} + app: redis +spec: + replicas: 1 + selector: + matchLabels: + app: redis + template: + metadata: + labels: + app: redis + spec: + containers: + - name: redis + image: redis:5.0.4 + command: + - redis-server + - "/redis-master/redis.conf" + env: + - name: MASTER + value: "true" + ports: + - containerPort: 6379 + resources: + limits: + cpu: "0.1" + volumeMounts: + - mountPath: /redis-master-data + name: data + - mountPath: /redis-master + name: config + volumes: + - name: data + emptyDir: {} + - name: config + configMap: + name: example-redis-config + items: + - key: redis-config + path: redis.conf +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: example-redis-config +data: + redis-config: "" diff --git a/charts/feathr-online-sandbox/templates/service.yaml b/charts/feathr-online-sandbox/templates/service.yaml new file mode 100644 index 0000000..646db57 --- /dev/null +++ b/charts/feathr-online-sandbox/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "feathr-online.fullname" . }} + labels: + {{- include "feathr-online.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 8000 + protocol: TCP + name: http + selector: + {{- include "feathr-online.selectorLabels" . | nindent 4 }} diff --git a/charts/feathr-online-sandbox/values.yaml b/charts/feathr-online-sandbox/values.yaml new file mode 100644 index 0000000..285fe63 --- /dev/null +++ b/charts/feathr-online-sandbox/values.yaml @@ -0,0 +1,51 @@ +# Default values for feathr-online. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: windoze/feathrpiper + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/feathr-online/.DS_Store b/charts/feathr-online/.DS_Store new file mode 100644 index 0000000..5c3247b Binary files /dev/null and b/charts/feathr-online/.DS_Store differ diff --git a/charts/feathr-online/kv b/charts/feathr-online/kv new file mode 100644 index 0000000..83c492b --- /dev/null +++ b/charts/feathr-online/kv @@ -0,0 +1,49 @@ + +1. Create an Azure Key Vault in Public or Private Subnet. *Should create it in another subnet that agent-pool is not in +az keyvault create -n feathr-aks-key-vault -g feathr-aks -l southeastasia + +2. +az keyvault secret set --vault-name feathr-aks-key-vault -n CONN-STR --value CONN_STR +Parameter 'secret_name' must conform to the following pattern: '^[0-9a-zA-Z-]+$'. + +3. +az aks show -g feathr-aks -n feathr-aks --query addonProfiles.azureKeyvaultSecretsProvider.identity.clientId -o tsv +5a98b518-43a7-41de-817f-bbd118e965f9 + + +az identity create -g feathr-aks -n feathr-aks-identity +az vmss identity assign -g MC_feathr-aks_feathr-aks_southeastasia -n aks-agentpool-32719613-vmss --identities /subscriptions/78970632-6536-4ba2-a247-d80222ec6a83/resourcegroups/feathr-aks/providers/Microsoft.ManagedIdentity/userAssignedIdentities/feathr-aks-identity + +4. + +# set policy to access keys in your key vault +az keyvault set-policy -n feathr-aks-key-vault --key-permissions get --spn 080d6eaa-af6f-4b76-b520-04c8c5dad49e +# set policy to access secrets in your key vault +az keyvault set-policy -n feathr-aks-key-vault --secret-permissions get --spn 080d6eaa-af6f-4b76-b520-04c8c5dad49e +# set policy to access certs in your key vault +az keyvault set-policy -n feathr-aks-key-vault --certificate-permissions get --spn 080d6eaa-af6f-4b76-b520-04c8c5dad49e + +# This is a SecretProviderClass example using user-assigned identity to access your key vault +apiVersion: secrets-store.csi.x-k8s.io/v1 +kind: SecretProviderClass +metadata: + name: azure-kvname-user-msi +spec: + provider: azure + parameters: + usePodIdentity: "false" + useVMManagedIdentity: "true" # Set to true for using managed identity + userAssignedIdentityID: # Set the clientID of the user-assigned managed identity to use + keyvaultName: # Set to the name of your key vault + cloudName: "" # [OPTIONAL for Azure] if not provided, the Azure environment defaults to AzurePublicCloud + objects: | + array: + - | + objectName: secret1 + objectType: secret # object types: secret, key, or cert + objectVersion: "" # [OPTIONAL] object versions, default to latest if empty + - | + objectName: key1 + objectType: key + objectVersion: "" + tenantId: # The tenant ID of the key vault \ No newline at end of file diff --git a/charts/feathr-online/templates/redis.yaml b/charts/feathr-online/templates/redis.yaml new file mode 100644 index 0000000..efcf34c --- /dev/null +++ b/charts/feathr-online/templates/redis.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "feathr-online.fullname" . }}-redis + labels: + {{- include "feathr-online.labels" . | nindent 4 }} + app: redis +spec: + replicas: 1 + selector: + matchLabels: + app: redis + template: + metadata: + labels: + app: redis + spec: + containers: + - name: redis + image: redis:5.0.4 + command: + - redis-server + - "/redis-master/redis.conf" + env: + - name: MASTER + value: "true" + ports: + - containerPort: 6379 + resources: + limits: + cpu: "0.1" + volumeMounts: + - mountPath: /redis-master-data + name: data + - mountPath: /redis-master + name: config + volumes: + - name: data + emptyDir: {} + - name: config + configMap: + name: example-redis-config + items: + - key: redis-config + path: redis.conf +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: example-redis-config +data: + redis-config: ""