glcoud beta code dev launches the Google Cloud Run Emulator.
(Mac OS 12.1, M1 ARM)
In VSCode, this works, with
Starting deploy...
Waiting for deployments to stabilize...
Deployments stabilized in 1.103 second
Watching for changes...
Service URL: http://localhost:8080/
If I run the same command from my system terminal (just the vanilla, default terminal on M1 Mac), it fails with
Starting deploy...
WARN[0015] Skipping deploy due to error:kubectl create: starting command ~/google-cloud-sdk/bin/kubectl --context gcloud-local-dev create --dry-run=client -oyaml -f /var/folders/vc/ajfl_bjoi3hghaooeihghaf/T/deploy_ou_9015s.yaml: pipe: too many open files subtask=-1 task=DevLoop
Watching for changes...
I've tried both zsh and fish, in case it's a shell thing, but no.
I also made sure to shut down what's going on in one terminal before trying the other.
What could be causing this?
EDIT:
gcloud --version outputs
Google Cloud SDK 367.0.0
beta 2021.12.10
bq 2.0.72
core 2021.12.10
gsutil 5.5
kubectl 1.20.8
minikube 1.24.0
skaffold 1.34.0
Related
I spent several hours looking at this Lens error for K8s. I installed Python, OCI-CLI for Windows 10 (I downloaded oci-cli offline installation, and run python install.py) and configured cluster access. Using CMD works ok:
kubectl command works fine, even get pods command works
But using Lens it gives me the error when connecting
Error getting Credentials: exec: executable oci not found
What am I missing?
I finally found the solution, it was to download kubectl.exe
https://storage.googleapis.com/kubernetes-release/release/v1.21.0/bin/windows/amd64/kubectl.exe
I put it in a folder on the disk, example c:\kubenetes
add that folder to the PATH environment variable.
Restart the PC. Without reboot it didn't work.
Any hints on why Remote - Containers isn't working with podman on Windows?
Installed podman v4.2.0 on Windows 11 via .msi package
Set remote.containers.dockerPath to podman in VS Code Settings
Run podman machine init
Run podman machine start
Open Remote Explorer in VS Code and be presented with the following:
Everything is working with podman — pull, run, images, etc, but Remote - Containers on VSCode doesn't recognize podman.
After running Remote-Containers Developer: Show All Logs... in VS Code:
[2022-08-21T12:55:15.916Z] Start: Run: podman version --format {{.Server.APIVersion}}
[2022-08-21T12:55:16.080Z] Stop (164 ms): Run: podman version --format {{.Server.APIVersion}}
[2022-08-21T12:55:16.080Z] Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman. failed to create sshClient: dial unix \\.\pipe\openssh-ssh-agent: connect: No connection could be made because the target machine actively refused it.
And podman system connection list in a terminal:
Name URI Identity Default
podman-machine-default ssh://user#localhost:62078/run/user/1000/podman/podman.sock C:\Users\Edmundo\.ssh\podman-machine-default true
podman-machine-default-root ssh://root#localhost:62078/run/podman/podman.sock C:\Users\Edmundo\.ssh\podman-machine-default false
Related Issues: #6957, #6747.
Please confirm you are running the latest build (prerelease)
v0.236.1.
(there are known issues on github with earlier release, fixed in this version)
in a WSL shell, i.e. for debugging try this
first - try to start podman podlib REST api (for socket, lifetime 5000 sec. - set to zero for "forever")
podman system service -t 5000 &
then symlink the podman.sock to the location vscode expects:
sudo ln -s /mnt/wslg/runtime-dir/podman/podman.sock /var/run/docker.sock
if none of that works, would you mind posting a dump:
podman info
HINT: check the podman info YAML output for host | remoteSocket | path & make sure it matches the path /mnt/wslg/runtime-dir/podman/podman.sock above.
The bug being tracked on GitHub. One step you should also do is enable Run in WSL in VS Code Development Container extension settings. Then it will run the podman commands in the podman-machine-default wsl instance.
When I run a simple command, it takes about 10 seconds to complete,
λ time gcloud version
Google Cloud SDK 293.0.0
beta 2019.05.17
bq 2.0.57
core 2020.05.15
gsutil 4.50
real 0m9.731s
user 0m0.735s
sys 0m1.690s
λ uname -a
Linux LAPTOP-U7E4CROH 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
λ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
I should note that I do not experience this slow behavior on the same laptop but within a git-bash environment - I only see this within WSL2 / Ubuntu.
I have tried to google around and I have found these two questions on SO, but they are not helping me:
google compute engine tool gcloud is exceptionally slow
Why gcloud command is slow to start?
Any ideas on how I can solve this?
I have the same issue and it turns out that in WSL 2 when I run gcloud it actually turn to use the gcloud installed on my Windows system.
Somehow it is very slow if you run the Windows gcloud from WSL 2, which is also never my intention.
I just disable appending Windows PATH to my WSL PATH all together after this.
But you know the root cause.
For the sake of completeness, to disable this feature, edit the /etc/wsl.conf to add the following section:
[interop]
appendWindowsPath = false
and terminate the WSL distro (wsl.exe --terminate <distro_name>) to make it immediately effective.
I had the same issue, resolved it by reinstalling the SDK: https://cloud.google.com/sdk/docs/downloads-interactive#linux
You must reinstall using 'Interactive installation', which replaces the previous installation and updates the PATH.
'Non-interactive (silent) deployment' does not seem to improve the issue.
Hope this helps.
I had the same issue and the only solution that worked for me was to set an alias for the gcloud command such that it gets executed by cmd.exe like so:
# in ~/.bashrc
alias gcloud="cmd.exe /c gcloud"
Then simply restart your terminal or run $ source ~/.bashrc, and the alias will take effect.
Of course, this assumes you have the gcloud CLI installed and added to your windows PATH.
I am trying to use rules_k8s for Bazel to deploy to my Kubernetes cluster.
Thus I have this cloudbuild.yaml file, which is executed by Google Cloud Build:
steps:
- name: gcr.io/cloud-builders/bazel
args: ['run', '//:kubernetes.apply']
(//:kubernetes is just a k8s_objects)
On my local machine running bazel run //:kubernetes.apply works fine, but
although the Google Cloud Build succeeds, it logs those errors. So the configuration is not applied to my Kubernetes cluster:
Target //:kubernetes.apply up-to-date:
bazel-bin/kubernetes.apply
INFO: Elapsed time: 29.863s, Critical Path: 0.14s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/kubernetes.apply
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, 1 total action
kubectl toolchain was not properly configured so k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_service.apply cannot be executed.
kubectl toolchain was not properly configured so projection_database_k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so projection_database_k8s_service.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_service.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_service.apply cannot be executed.
kubectl toolchain was not properly configured so event_store_k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so event_store_k8s_service.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_service.apply cannot be executed.
kubectl toolchain was not properly configured so event_store_k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so event_store_k8s_service.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so k8s_service.apply cannot be executed.
kubectl toolchain was not properly configured so event_store_k8s_deployment.apply cannot be executed.
kubectl toolchain was not properly configured so event_store_k8s_service.apply cannot be executed.
I also get a warning from the bazel cache:
DEBUG: /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/io_bazel_rules_k8s/toolchains/kubectl/kubectl_toolchain.bzl:28:9: No kubectl tool was found or built, executing run for rules_k8s targets might not work.
P.S.: I get the same errors when using //:kubernetes.create
My setup
Deployments
load("#io_bazel_rules_k8s//k8s:object.bzl", "k8s_object")
k8s_object(
name = "k8s_deployment",
kind = "deployment",
cluster = "gke_cents-ideas_europe-west3-a_cents-ideas",
template = ":ideas.deployment.yaml",
images = {
"gcr.io/cents-ideas/ideas:latest": ":image"
},
)
Services
k8s_object(
name = "k8s_service",
kind = "service",
cluster = "gke_cents-ideas_europe-west3-a_cents-ideas",
template = ":ideas.service.yaml",
)
Aggregations
load("#io_bazel_rules_k8s//k8s:objects.bzl", "k8s_objects")
k8s_objects(
name = "k8s",
objects = [
":k8s_deployment",
":k8s_service",
]
)
Final composition
k8s_objects(
name = "kubernetes",
objects = [
"//services/ideas:k8s",
# ...
]
)
Update
I've now tried to make my own docker image with Bazel and kubectl:
FROM gcr.io/cloud-builders/bazel
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl
I pushed it to GCR and changed my cloudbuild.yaml to:
steps:
- name: eu.gcr.io/cents-ideas/bazel-kubectl
args: ["run", "//:kubernetes.apply"]
I firstly noticed, that the step took way longer than before. However at the end it throws an error:
$ /usr/local/bin/kubectl --kubeconfig= --cluster=gke_cents-ideas_europe-west3-a_cents-ideas --context= --user= apply -f -
error: cluster "gke_cents-ideas_europe-west3-a_cents-ideas" does not exist
Here is the full log.
As for the updated question, now you need to authenticate somehow to GKE inside the container.
First thing, I recommend installing gcloud tool to your container.
Btw, as for the huge container size 1.2 GB, that's because cloud-builders/bazel is huge :)
Have a look at our example on slim bazel container version:
https://github.com/aspect-development/bazel-k8s-example/blob/master/tools/Dockerfile.dazel
And here is Dockerfile for installing gcloud and kubectl, so you can grab needed parts from both files:
https://github.com/GoogleCloudPlatform/cloud-builders/blob/master/gcloud/Dockerfile
The second thing is authenticating, after gcloud is installed it should be easy.
Overall cloudbuild step should look similar to this:
- name: <link to your container>
entrypoint: /bin/sh
args:
- -c
- |
gcloud container clusters get-credentials cents-ideas --zone europe-west3-a --project cents-ideas
bazel run //:kubernetes.apply
It complains that it can't find kubectl on your machine. If GKE is used, also the gcloud sdk needs to be installed.
And also check that authentication is configured for those tools: kubectl auth, GKE auth.
The main issue is that kubectl doesn't come with the gcr.io/cloud-builders/bazel docker image. That is why it can't be found.
There are however, efforts to implement the kubectl toolchain into Bazel manually: https://github.com/bazelbuild/rules_k8s/tree/master/toolchains/kubectl#kubectl-toolchain. But as those features are currently in experimental status, they often don't work.
More info can be found in this issue: https://github.com/bazelbuild/rules_k8s/issues/512
For now, your best bet will be to install kubectl in the container.
I found such command as docker-compose down on docker website, but when I try to use it i get an error.
No such command: down
Commands:
build Build or rebuild services
help Get help on a command
kill Kill containers
logs View output from containers
port Print the public port for a port binding
ps List containers
pull Pulls service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
up Create and start containers
migrate-to-labels Recreate containers to add labels
My docker-compose version is:
docker-compose version: 1.3.1
CPython version: 2.7.10
OpenSSL version: OpenSSL 1.0.2d 9 Jul 2015
Did I do something wrong?
It might be that docker-compose down command is not available in the version you use - the command was added in version 1.6.0 - see the CHANGELOG here.
So if you really want to use the command, you may have to upgrade to version 1.6.0 or later.
Hope this helps.