-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add k8s grid deployments (#26359)
- Loading branch information
1 parent
ffd6cf6
commit 65ac0d5
Showing
15 changed files
with
296 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM mcr.microsoft.com/playwright:v1.37.0-alpha-aug-7-2023-jammy | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json ./ | ||
COPY cli.js ./ | ||
COPY lib ./lib | ||
RUN npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: grid-deployment | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: grid | ||
template: | ||
metadata: | ||
labels: | ||
app: grid | ||
spec: | ||
containers: | ||
- name: grid | ||
image: playwright-grid | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: DEBUG | ||
value: "pw:grid*" | ||
- name: PLAYWRIGHT_GRID_ACCESS_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: access-key-secret | ||
key: access-key | ||
command: ["node", "./cli.js"] | ||
args: ["grid", "--port=3000"] | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: grid-service | ||
spec: | ||
selector: | ||
app: grid | ||
ports: | ||
- protocol: TCP | ||
port: 3000 | ||
targetPort: 3000 | ||
type: LoadBalancer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: worker-deployment | ||
spec: | ||
replicas: 10 # or however many nodes you want | ||
selector: | ||
matchLabels: | ||
app: worker | ||
template: | ||
metadata: | ||
labels: | ||
app: worker | ||
spec: | ||
containers: | ||
- name: grid | ||
image: playwright-grid | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: DEBUG | ||
value: "pw:grid*" | ||
- name: PLAYWRIGHT_GRID_ACCESS_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: access-key-secret | ||
key: access-key | ||
command: ["node", "./cli.js"] | ||
args: ["node", "--grid=grid-service:3000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
```sh | ||
# Create resource group | ||
az group create --name group-grid-001 --location westus3 | ||
|
||
# Create ACR | ||
az acr create --resource-group group-grid-001 --name acrgrid001 --sku Basic | ||
az acr login --name acrgrid001 | ||
az acr list --resource-group group-grid-001 --query "[].{acrLoginServer:loginServer}" --output table | ||
|
||
# Create AKS | ||
az aks create --resource-group group-grid-001 --name aks-grid-001 --node-count 4 --enable-addons monitoring --generate-ssh-keys | ||
az aks get-credentials --resource-group group-grid-001 --name aks-grid-001 | ||
|
||
# Grant AKS access to ACR | ||
az aks show --resource-group group-grid-001 --name aks-grid-001 --query "servicePrincipalProfile.clientId" --output tsv | ||
# az aks show --resource-group group-grid-001 --name aks-grid-001 --query "identityProfile.kubeletidentity.clientId" -o tsv | ||
# az acr show --name acrgrid001 --resource-group group-grid-001 --query "id" -o tsv | ||
# az role assignment create --assignee <GUID> --role AcrPull --scope <SCOP PATH> | ||
|
||
# Create secrets | ||
kubectl create secret generic access-key-secret --from-literal=access-key=$PLAYWRIGHT_GRID_ACCESS_KEY | ||
|
||
# Create TLS | ||
# kubectl create secret tls grid-tls-secret --cert=../../tests/config/testserver/cert.pem --key=../../tests/config/testserver/key.pem | ||
# az network public-ip create --resource-group MC_group-grid-001_aks-grid-001_westus3 --name public-ip-grid-001 --sku Standard --allocation-method static | ||
# az network public-ip show --resource-group MC_group-grid-001_aks-grid-001_westus3 --name public-ip-grid-001 --query ipAddress --output tsv | ||
# # use output below | ||
# helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx | ||
# helm install nginx-ingress ingress-nginx/ingress-nginx \ | ||
# --set controller.replicaCount=1 \ | ||
# --set controller.nodeSelector."beta\.kubernetes\.io/os"=linux \ | ||
# --set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux \ | ||
# --set controller.service.loadBalancerIP="20.118.130.255" | ||
|
||
# Push Docker container | ||
docker build -t playwright-grid:latest -f Dockerfile . | ||
docker tag playwright-grid acrgrid001.azurecr.io/playwright-grid | ||
docker push acrgrid001.azurecr.io/playwright-grid | ||
|
||
# Delete deployment | ||
kubectl delete deployment grid-deployment | ||
kubectl delete deployment worker-deployment | ||
kubectl delete svc grid-service | ||
|
||
# Update deployment | ||
kubectl apply -f deployment-grid.yaml | ||
kubectl apply -f deployment-worker.yaml | ||
|
||
# Debug | ||
kubectl get pods -l app=grid | ||
kubectl logs grid-6cbbfc866c-wh8dw | ||
kubectl get pods -n ingress-basic | ||
kubectl get svc grid-service | ||
az aks show --resource-group group-grid-001 --name aks-grid-001 --query fqdn --output tsv | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
```sh | ||
minikube config set memory 65536 | ||
minikube config set cpus 12 | ||
minikube start | ||
minikube dashboard | ||
|
||
# Point docker to minikube | ||
minikube -p minikube docker-env | ||
eval $(minikube docker-env) | ||
kubectl config use-context minikube | ||
kubectl create secret generic access-key-secret --from-literal=access-key=$PLAYWRIGHT_GRID_ACCESS_KEY | ||
|
||
# Push Docker container | ||
docker build -t playwright-grid:latest -f Dockerfile . | ||
|
||
# Delete deployment | ||
kubectl delete deployment grid-deployment | ||
kubectl delete deployment worker-deployment | ||
kubectl delete svc grid-service | ||
|
||
# Update deployment | ||
|
||
kubectl apply -f deployment-grid.yaml | ||
kubectl apply -f deployment-worker.yaml | ||
|
||
# Debug | ||
minikube ip | ||
kubectl get svc grid-service | ||
kubectl get pods -l app=grid | ||
kubectl logs grid-6cbbfc866c-wh8dw | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.