From 5ea00791f7fe1a9b295a96831943bd9d340c479a Mon Sep 17 00:00:00 2001 From: Abhishek Bhagwat Date: Tue, 29 Oct 2024 21:14:28 +0000 Subject: [PATCH] try to fix linter; roll back nginx --- .github/actions/spelling/allow.txt | 8 + .../claude/computer-use-demo/README.md | 8 +- .../computer-use-demo/cloudbuild-destroy.yaml | 14 ++ .../claude/computer-use-demo/cloudbuild.yaml | 20 +- .../claude/computer-use-demo/deployment.yaml | 223 ++++++------------ 5 files changed, 107 insertions(+), 166 deletions(-) diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index 3d6875030d3..fd7867d403e 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -77,6 +77,7 @@ ESG Eliud Embs Envane +envsubst Esin Eventarc FAISS @@ -115,6 +116,7 @@ GmbH Googlers HDFC HIDPI +HIGHCPU HMO HREDRAW HSA @@ -163,6 +165,7 @@ Kipchoge Knopf Kohli Kraizt +KSA Kubeflow Kudrow LCEL @@ -218,6 +221,7 @@ Niitsuma Nintendo Nominatim Noogler +novnc ODb OOTB Oberst @@ -799,11 +803,13 @@ vapo vectordb vertexai vesselin +vnc vtotal waterjet wcontext wcslen websites +webpages welcom wiffle windspeed @@ -814,6 +820,7 @@ wparam wscore wscores wstring +WXGA xaxes xaxis xcassets @@ -821,6 +828,7 @@ xcconfig xcodeproj xcscheme xctest +XGA xlabel xmltodict xsi diff --git a/partner-models/claude/computer-use-demo/README.md b/partner-models/claude/computer-use-demo/README.md index 274f61986e1..b4b6e4e0572 100644 --- a/partner-models/claude/computer-use-demo/README.md +++ b/partner-models/claude/computer-use-demo/README.md @@ -30,7 +30,7 @@ Please use [this form](https://forms.gle/BT1hpBrqDPDUrCqo7) to provide feedback ## Quickstart: Deploying the app on Google Cloud using GKE and Cloud Build -We provide a simplied way to deploy this app on Google Cloud using Google Kubernetes Engine (GKE). To set this up, follow the steps below. +We provide a simplified way to deploy this app on Google Cloud using Google Kubernetes Engine (GKE). To set this up, follow the steps below. 1. Set up the environment variables @@ -93,9 +93,9 @@ The container stores settings like the API key and custom system prompt in `~/.a Alternative access points: -- Streamlit interface only: [http://localhost:8501](http://localhost:8501) -- Desktop view only: [http://localhost:6080/vnc.html](http://localhost:6080/vnc.html) -- Direct VNC connection: `vnc://localhost:5900` (for VNC clients) +* Streamlit interface only: [http://localhost:8501](http://localhost:8501) +* Desktop view only: [http://localhost:6080/vnc.html](http://localhost:6080/vnc.html) +* Direct VNC connection: `vnc://localhost:5900` (for VNC clients) ## Screen size diff --git a/partner-models/claude/computer-use-demo/cloudbuild-destroy.yaml b/partner-models/claude/computer-use-demo/cloudbuild-destroy.yaml index dc95f053be3..df994d03942 100644 --- a/partner-models/claude/computer-use-demo/cloudbuild-destroy.yaml +++ b/partner-models/claude/computer-use-demo/cloudbuild-destroy.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + steps: - id: 'delete-k8s-resources' name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' diff --git a/partner-models/claude/computer-use-demo/cloudbuild.yaml b/partner-models/claude/computer-use-demo/cloudbuild.yaml index c4b409c2ede..9ba9f458fa2 100644 --- a/partner-models/claude/computer-use-demo/cloudbuild.yaml +++ b/partner-models/claude/computer-use-demo/cloudbuild.yaml @@ -37,26 +37,18 @@ steps: --quiet fi - - id: 'pull-tag-push-image' + - id: 'build-push-image' name: 'gcr.io/cloud-builders/docker' waitFor: ['setup-artifact-registry'] - entrypoint: 'bash' args: - - '-c' - - | - # Pull the prebuilt image - docker pull ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest - - # Tag for Artifact Registry - docker tag ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest \ - ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_ARTIFACT_REGISTRY_ID}/${_IMAGE_NAME}:${_IMAGE_TAG} - - # Push to Artifact Registry - docker push ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_ARTIFACT_REGISTRY_ID}/${_IMAGE_NAME}:${_IMAGE_TAG} + - 'build' + - '-t' + - '${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_ARTIFACT_REGISTRY_ID}/${_IMAGE_NAME}:${_IMAGE_TAG}' + - '.' - id: 'setup-k8s-iam' name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' - waitFor: ['pull-tag-push-image'] + waitFor: ['build-push-image'] entrypoint: 'bash' args: - '-c' diff --git a/partner-models/claude/computer-use-demo/deployment.yaml b/partner-models/claude/computer-use-demo/deployment.yaml index 121476d1237..54d69b49037 100644 --- a/partner-models/claude/computer-use-demo/deployment.yaml +++ b/partner-models/claude/computer-use-demo/deployment.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + apiVersion: v1 kind: ServiceAccount metadata: @@ -6,88 +20,6 @@ metadata: annotations: iam.gke.io/gcp-service-account: ${_IAM_SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com --- -apiVersion: v1 -kind: ConfigMap -metadata: - name: nginx-config - namespace: ${_NAMESPACE} -data: - nginx.conf: | - events { - worker_connections 1024; - } - http { - server { - listen 8080; - - # Enable localhost redirects - server_name localhost 127.0.0.1; - - # Serve the main app files - location / { - root /usr/share/nginx/html; - index index.html; - sub_filter 'http://localhost:8501' ''; - sub_filter 'http://127.0.0.1:6080' ''; - sub_filter_once off; - sub_filter_types *; - } - - # Handle direct localhost:8501 access - location = /8501 { - return 302 $scheme://$host:8080/streamlit/; - } - - # Handle direct localhost:6080 access - location = /6080 { - return 302 $scheme://$host:8080/vnc/; - } - - # Proxy for Streamlit - location /streamlit/ { - proxy_pass http://127.0.0.1:8501/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_read_timeout 86400; - } - - # Rewrite localhost:8501 to /streamlit/ - location ~ ^http://localhost:8501/(.*)$ { - return 302 $scheme://$host:8080/streamlit/$1; - } - - # Proxy for noVNC - location /vnc/ { - proxy_pass http://127.0.0.1:6080/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_read_timeout 86400; - } - - # Rewrite localhost:6080 to /vnc/ - location ~ ^http://127.0.0.1:6080/(.*)$ { - return 302 $scheme://$host:8080/vnc/$1; - } - - # Proxy for main app - location /app/ { - proxy_pass http://127.0.0.1:8088/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_read_timeout 86400; - } - } - } ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -104,70 +36,56 @@ spec: app: ${_IMAGE_NAME} spec: serviceAccountName: ${_KSA_NAME} - volumes: - - name: nginx-config - configMap: - name: nginx-config containers: - - name: nginx-proxy - image: nginx:alpine - ports: - - containerPort: 8080 - volumeMounts: - - name: nginx-config - mountPath: /etc/nginx/nginx.conf - subPath: nginx.conf - - name: ${_IMAGE_NAME} - image: ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_ARTIFACT_REGISTRY_ID}/${_IMAGE_NAME}:${_IMAGE_TAG} - resources: - requests: - memory: "1Gi" - cpu: "1000m" - limits: - memory: "2Gi" - cpu: "1000m" - env: - - name: API_PROVIDER - value: "vertex" - - name: CLOUD_ML_REGION - value: "${_REGION}" - - name: ANTHROPIC_VERTEX_PROJECT_ID - value: "${PROJECT_ID}" - - name: WIDTH - value: "1024" - - name: HEIGHT - value: "768" - - name: VNC_PORT - value: "5900" - - name: NOVNC_PORT - value: "6080" - - name: WEBSOCKIFY_OPTIONS - value: "--web /opt/noVNC --cert=/opt/noVNC/self.pem" - - name: HTTP_SERVER_PORT - value: "8088" - ports: - - containerPort: 5900 - name: vnc - - containerPort: 8501 - name: streamlit - - containerPort: 6080 - name: novnc - - containerPort: 8088 - name: web - readinessProbe: - tcpSocket: - port: streamlit - initialDelaySeconds: 90 - periodSeconds: 10 - timeoutSeconds: 5 - failureThreshold: 6 - livenessProbe: - tcpSocket: - port: web - initialDelaySeconds: 120 - periodSeconds: 20 - timeoutSeconds: 5 - failureThreshold: 6 + - name: ${_IMAGE_NAME} + image: ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_ARTIFACT_REGISTRY_ID}/${_IMAGE_NAME}:${_IMAGE_TAG} + resources: + requests: + memory: "1Gi" + cpu: "1000m" + limits: + memory: "2Gi" + cpu: "1000m" + env: + - name: API_PROVIDER + value: "vertex" + - name: CLOUD_ML_REGION + value: "${_REGION}" + - name: ANTHROPIC_VERTEX_PROJECT_ID + value: "${PROJECT_ID}" + - name: WIDTH + value: "1024" + - name: HEIGHT + value: "768" + - name: VNC_PORT + value: "5900" + - name: NOVNC_PORT + value: "6080" + - name: WEBSOCKIFY_OPTIONS + value: "--web /opt/noVNC --cert=/opt/noVNC/self.pem" + ports: + - containerPort: 5900 + name: vnc + - containerPort: 8501 + name: streamlit + - containerPort: 6080 + name: novnc + - containerPort: 8080 + name: web + readinessProbe: + tcpSocket: + port: streamlit + initialDelaySeconds: 90 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 6 + livenessProbe: + tcpSocket: + port: web + initialDelaySeconds: 120 + periodSeconds: 20 + timeoutSeconds: 5 + failureThreshold: 6 --- apiVersion: v1 kind: Service @@ -177,8 +95,17 @@ metadata: spec: type: LoadBalancer ports: - - port: 8080 - targetPort: 8080 - name: web + - port: 5900 + targetPort: vnc + name: vnc + - port: 8501 + targetPort: streamlit + name: streamlit + - port: 6080 + targetPort: novnc + name: novnc + - port: 8080 + targetPort: web + name: web selector: app: ${_IMAGE_NAME} \ No newline at end of file