Install on Ubuntu
Table of Contents
Docker
Install Docker Engine on Ubuntu
Step 1: Set up Docker's apt repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Step 2: Install the Docker packages.
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
OpenFaaS
Install on Kubernetes
Step 1: Create Kubernetes Namespace
kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml
Step 2: Helm charts
helm repo add openfaas https://openfaas.github.io/faas-netes/
helm repo update
helm upgrade openfaas --install openfaas/openfaas --namespace openfaas
(Optional) Step 3: Expose OpenFaaS Gateway Service to LoadBalancer
kubectl patch svc gateway-external -n openfaas -p '{"spec":{"type": "LoadBalancer"}}'
Step 4: Get OpenFaaS admin Password
PASSWORD=$(kubectl -n openfaas get secret basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode) && \
echo "OpenFaaS admin password: $PASSWORD"
Step 5: Login OpenFaaS WebUI via credential
# Default gateway endpoint is http://127.0.0.1:8080
faas-cli login -u admin -p $PASSWORD
# Specify gateway endpoint, for example http://10.0.0.196:31112
faas-cli login -u admin -p $PASSWORD -g http://10.0.0.196:31112
OpenFaaS Command Line Tool (faas-cli)
# via Homebrew
brew install faas-cli
# root user
curl -sSL https://cli.openfaas.com | sudo -E sh
# non-root user
curl -sSL https://cli.openfaas.com | sh
Build, Push, Deploy, Remove OpenFaaS Functions
Automatic (Recommend)
# default architecture is amd64
make faas-up
# if use multi-architecture then
make faas-up-multi-arch
# Specify gateway, for example Gateway is http://10.0.0.196:31112
make faas-up GATEWAY=http://10.0.0.196:31112
make faas-up-multi-arch GATEWAY=http://10.0.0.196:31112
Manual
Build OpenFaaS Functions
make faas-build
Push OpenFaaS Functions
make faas-push
Publish OpenFaaS Functions (Multi-Arch, Recommend)
publish = build + push
# build and push multi-arch functions image (linux/arm64,linux/amd64)
make faas-publish
Deploy OpenFaaS Functions
make faas-deploy
# Specify gateway, for example Gateway is http://10.0.0.196:31112
make faas-deploy GATEWAY=http://10.0.0.196:31112
Remove OpenFaaS Functions
make faas-remove
# Specify gateway, for example Gateway is http://10.0.0.196:31112
make faas-remove GATEWAY=http://10.0.0.196:31112
MinIO Object Storage for Linux
Server side
Install MinIO Server
cd ~
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
Launch MinIO Server
cd ~
mkdir ~/minio-data
~/minio server ~/minio-data --console-address :9001
Connect to MinIO WebUI via browser
MinIO WebUI default account: minioadmin
MinIO WebUI default password: minioadmin
http://<HOST_IP>:9001
# Example
http://10.0.0.196:9001
Client side
Install Minio Client
cd ~
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
Configuration MinIO Client
mc alias set <ALIAS_NAME> http://<HOST_IP>:9000 <ACCESS_KEY> <SECRET_KEY>
mc admin info <ALIAS_NAME>
# Example
mc alias set local http://10.0.0.196:9000 minioadmin minioadmin
mc admin info local
Python Client API
from minio import Minio
def connect_minio():
"""Connect to MinIO Server"""
MINIO_API_ENDPOINT = os.environ["minio_api_endpoint"]
MINIO_ACCESS_KEY = os.environ["minio_access_key"]
MINIO_SECRET_KEY = os.environ["minio_secret_key"]
return Minio(
MINIO_API_ENDPOINT,
access_key=MINIO_ACCESS_KEY,
secret_key=MINIO_SECRET_KEY,
secure=False # Disable HTTPS
)
Last modified: 30 November 2024