Is it possible to edit Cloud Functions via SSH on VS Code? - visual-studio-code

I know how to develop using Linux VMs and SSH on VS Code, but now I am using Cloud Functions and I would like to debug it on VS Code or any other editor/IDE, is it possible?

Yes, it is possible to debug the code that you are going to deploy into Cloud Functions in your favorite IDE. As the opposite to Compute Engine you can't ssh into Cloud Functions. Cloud Functions is based on preemptible Compute Engine instances, this means that you have no control at all over the instances and you can't ssh into them.
What you can actually do is develop your function as a small, idempotent piece of code, test it locally and then deploy it to Cloud Functions directly from your IDE, then if you want to see the logs of your function you can run the gcloud functions logs command directly on your ide

Related

Is there a way to run an IDE like VSCode from a cloud instance?

I know that with R you can run RStudio as a browser instance directly from a server/cloud instance, so you access the IDE via browser, and that IDE has access to files/data available on that instance (similar to what Jupyterlab does).
Similarly i wonder if there is a way to run VSCode (or some other full feature IDE) as a browser instance on something like a google dataproc, so instead of using Jupyter to run code and access data, you would use the IDE.
I realize there are ways to run a local instance of an IDE and connect to a server/cloud instance, but in some cases these connections are blocked by firewalls and you have no way of running code on the instance other than via browser/jupyter, so i was wondering if there was some other way to do this.
As #guillaume blaquiere suggested :
Cloud Workstation is the brand new feature is designed for that
Fully managed development environments built to meet the needs of security-sensitive enterprises. It enhances the security of development environments while accelerating developer onboarding and productivity.
Access secure and fast development environments anytime via browser or local IDE
Enable administrators to easily provision, scale, manage, and secure development environments
Customize development environments with your preferred IDE and through custom container images

How to connect VScode to colab / paperspace / etc

Cloud instances like google colab, paperspace gradient etc. offer free or very inexpensive options at ~10$/months for storage, GPU compute, ready-to-use containers and a jupyter notebook/lab IDE. It's great for hobby prototypes.
However, personally, I much prefer IDEs like VSCode for developing even small projects. Given that VSCode offers ssh-remote access to machines and even docker containers, what are the best options to realize this? Already tried colab-ssh which works but feels a bit sluggish. Maybe there are better options?
On the other side, one can rent instances like AWS p2.xlarge, but with costs of 1$/h they become significantly more expensive than the above options (sidenote: Why is there such a discrepancy?)
SSH onto notebook server
Most managed notebook services don't allow/support SSH.
Colab states this in its terms of service.
Paperspace also seems to not support it (according to this forum thread from 2018).
It may be possible with Sagemaker if you set up a bastion host.
VS Code server
VS Code server you lets you run VS Code on the notebook server, and connect through a local VS Code without SSH.
in Colab: colabcode
in Paperspace: gradient-coder
On the client side you can connect via the Remote - Tunnels extension.

Using VSCode to launch apps in GCP

not sure if this has been asked before though I couldn't find it. I am using GCP services such as app engine, secret manager and storage but am using the Cloud Shell editor. Though I like it, I prefer coding on VScode due to familiarity. Any help on how could I achieve this on my VS code terminal?
#Sachin - We have support for all the features that are available in Cloud Shell in the local VSCode IDE through the cloud code plugin. Here is where you want to get started.
Quick start & Install
Plugin on VSCode Marketplace

How to use Kind instead of Minikube with Cloud Code?

For reasons of resources (memory and processor), I cannot install Minikube on my pc. While I need it to use Cloud Code's Cloud Run Emulator. I replaced Minikube with Kind and wanted to know how to configure Cloud Code to use Kind.
Unfortunately it looks like Cloud Code doesn't currently support configuring the Cloud Run Emulator to use anything other than minikube.
Updating your kubeconfig with your kind cluster works for running on Kubernetes with Cloud Code, but not for Cloud Run.
Looks like you might be stuck with running locally using Docker if you can't install minikube.

Learning to use Kuberentes on one single computer

I'm in the need of learning how to use Kubernetes. I've read the first sentences of a couple of introductory tutorials, and never have found one which explains me, step by step, how to build a simulated real world example on a single computer.
Is Kubernetes by nature so distributed that even the 101-level tutorials can only be performed on clusters?
Or can I learn (execute important examples) the important stuff there is to know by just using my Laptop without needing to use a stack of Raspberry Pi's, AWS or GCP?
The easiest might be minikube.
Minikube is a tool that makes it easy to run Kubernetes locally.
Minikube runs a single-node Kubernetes cluster inside a VM on your
laptop for users looking to try out Kubernetes or develop with it
day-to-day.
For a resource that explains how to use this, try this getting started guide. It runs through an entire example application using a local development environment.
If you are okay with using Google Cloud Platform (I think one gets free credits initially), there is hello-node.
If you want to run the latest and greatest (not necessary stable) and you're using Linux, is also possible to spin up a local cluster on Linux from a cloned copy of the kubernetes sources, using hack/local_up_cluster.sh.