gcloud app services provides browse, delete, list, set-traffic commands. Is it possible to stop/start services using the CLI?
You want to start/stop individual versions of services, not the whole services:
$ gcloud app versions stop --service my-service version1
$ gcloud app versions start --service my-service version1
See An Overview of App Engine for more information on the distinction between services and versions.
Related
My Database was down today and multiple applications in my cluster lost the connection with the database, but the Pod was Healthy (I know, I should have better Health Checks, but I don't). So, when the database was back online, the applications weren't able to connect again. So, I would like to restart all my Deployments. They share a label and are in the same Kubernetes namespace. We use ArgoCD to manage the applications.
In ArgoCD, I know I can restart all Deployments in one ArgoCD Application by typing this command:
argocd app actions run my-app restart --kind Deployment --all
https://github.com/argoproj/argo-cd/blob/master/docs/user-guide/commands/argocd_app_actions_run.md
But I do not know how to restart the Deployment of multiple independent applications in ArgoCD. I tried, but none of these work:
argocd app actions run my-app1 my-app2 restart --kind Deployment --all
argocd app actions run -l mylabel=value restart --kind Deployment --all
I wonder how can I restart multiple applications in ArgoCD in one command?
I would like to use same syntax of the sync command (https://github.com/argoproj/argo-cd/blob/master/docs/user-guide/commands/argocd_app_sync.md):
argocd app sync [APPNAME... | -l selector] [flags]
I tried to use sync, but it does not restart Deployments, unless I make some change in the Deployment itself (or if I use a configMap Generator, which is not my case).
Thank you in advance.
EDIT: I created a shell script for my needs:
for i in $(argocd app list -l yourgroup=your.label --output name); do
argocd app actions run $i restart --kind Deployment --all;
done
It will fail for those apps which does not have a Deployment, but, for me, restarted everything I wanted.
I would like to change my deployed(GKE) Helm Chart values file with the ones that are inside my local file, basically to do this:
helm upgrade -f new-values.yml {release name} {package name or path}
So I've make all the changes inside my local file, but the deployment is inside the GKE cluster.
I've connected to my cluster via ssh, but how can I run the above command in order to perform the update if the file with the new values is on my local machine and the deployment is inside GKE cluster?
Maybe somehow via the scp command?
Solution by setting up required tools locally (you need a while or two for that)
You just need to reconfigure your kubectl client, which can be done pretty straighforward. When you log in to GCP Console -> go to Kubernetes Engine -> Clusters -> click on Actions (3 vertical dots to the right of the cluster name) -> select Connect -> copy the command, which may resemble the following one:
gcloud container clusters get-credentials my-gke-cluster --zone europe-west4-c --project my-project
It assumes you have your Cloud SDK and kubectl already installed on your local machine. If you have not, here you have step-by-step description how to do that:
Installing Google Cloud SDK [Debian/Ubuntu] (if you use a different OS, simply choose another tab)
Installing kubectl tool [Debian/Ubuntu] (choose your OS if it is something different)
Once you run the above command on your local machine, your kubectl context will be automatically set to your GKE Cluster even if it was set before e.g. to your local Minikube instance. You can check it by running:
kubectl config current-context
OK, almost done. Did I also mention helm ? Well, you will also need it. So if you have not installed it on your local machine previously, please do it now:
Install helm [Debian/Ubuntu]
Alternative slution using Cloud Shell (much quicker)
If installing and configuring it locally seems to you too much hassle, you can simply use a Cloud Shell (I bet you've used it before). In case you didn't, once logged in to your GCP Console click on the following icon:
Once logged into Cloud Shell, you can choose to upload your local files there:
simply click on More (3 dots again):
and choose Upload a file:
Do I need to install an instance of Spring Cloud Data Flow on the master server myself, or is this getting installed "automatically" as part of the deployment?
This isn't quite clear from the description at
http://docs.spring.io/spring-cloud-dataflow-server-kubernetes/docs/current-SNAPSHOT/reference/htmlsingle/#_deploying_streams_on_kubernetes
I've followed the guide, though removed every config for MySQL. Maybe this is required. Though I'm somewhat stuck since it's just not assigning an external IP and I do not see why, how to debug, and whether I missed to install some required component.
Edit:
To clarify, I see a scdf service entry when I run
kubectl get svc
But this service never gets an external IP.
Do I need to install an instance of Spring Cloud Data Flow on the master server myself, or is this getting installed "automatically" as part of the deployment?
Spring Cloud Data Flow server needs to be setup either outside (that knows how to connect to the kubernetes environment) or you can use the Spring Cloud Data Flow server docker image to run inside the kubernetes while the latter approach is better.
Step 6 in the link you posted above runs the SCDF docker image inside the kubernetes cluster:
```
Deploy the Spring Cloud Data Flow Server for Kubernetes using the Docker image and the configuration settings you just modified.
$ kubectl create -f src/etc/kubernetes/scdf-config-kafka.yml
$ kubectl create -f src/etc/kubernetes/scdf-secrets.yml
$ kubectl create -f src/etc/kubernetes/scdf-service.yml
$ kubectl create -f src/etc/kubernetes/scdf-controller.yml
```
MySql is required, that's why it's in the steps.
Spring Cloud Data Flow uses an RDBMS instead of Redis for stream/task
definitions, application registration, and for job repositories.
You can also use any of the other supported RDMBSes.
You can install it using Helm Charts.
https://dataflow.spring.io/docs/installation/kubernetes/helm/
At first install Helm
Then install Spring Cloud Data Flow
helm install --name my-release stable/spring-cloud-data-flow
It will install and config relevant pods such as spring-cloud-dataflow-server, mysql, skipper, rabbitmq, etc.
Also you can customize versions and configurations.
I created a Mongodb service according to the Kubernetes tutorial.
Now my question is how do I gain access to the database itself, with a client like Robomongo or similar clients? Just for making backups or exploring what data have been entered.
The mongo-pod and service only have an internal endpoint, and a single mount.
Is there any way to safely access this instance with no public endpoint?
Internally URI is mongo:27***
You can use kubectl port-forward mypod 27017:27017 and then just connect your mongodb client to localhost:27017.
If you want to stop, just hit Ctrl+C on the same cmd window to stop the process.
The kubernetes cmd-line tool provides this functionality as #ainlolcat stated
kubectl get pods
Retrieves the pod names currently running and with:
kubectl exec -i mongo-controller-* bash
you get a basic bash, which lets you execute
mongo
to get into the database to create dumps, and so on. The bash is very basic and has no features like completion and so on. I have not found a solution for better shell but it does the job
when you create a service in kubernetes you give it a name, say for example "mymongo". After the service is created then
The DNS service of kubernetes (by default is on) will ensure that any pod can discover this servixe simply by its name. so you can set your uri like
uri: mongodb://**mymongo**:27017/mong
In addition the service IP and port will be set as environment variables at the running pod.
MYMONGO_SERVICE_HOST
MYMONGO_SERVICE_PORT
I have in fact wrote a blog that show a step by step example of an app with nodejs web server and mongo that can explain further
http://codefresh.io/blog/kubernetes-snowboarding-everything-intro-kubernetes/
feedback welcome!
Answer from #grchallenge is correct but it is deprecated as of in 2021
All new comers please use
kubectl exec mongo-pod-name -i -- bash
I am using Google Cloud / Google Compute to host my application. I was on Google App Engine and I am migrating my code to Google Compute in order to use a customized VM Instance.
I am using the tutorial here, and I am deploying my app using:
$ gcloud preview app deploy
I setup a custom VM Instance using the "Create Instance" option at the top of my Google Cloud Console:
However, when I use the standard deploy gcloud command, my app is deployed to Managed VMs (managed by Google), and I have no control over those servers. I need to run the app on my custom VM because it has some custom OS-level software.
Any ideas on how to deploy the app to my custom VM Instance only? Even when I delete all the Managed VMs and try to deploy, the VMs are just re-created by Google.
The gcloud app deploy command can only be used to deploy the app to classic AppEngine sandboxed environment or to the Managed VMs. It cannot deploy your application to an instance running on GCE.
You will need to incorporate your own deployment method/script depending on the programming language you're using. Of course, since GCE is just an infrastructure-as-a-service environment (versus AppEngine being a platform-as-a-service), you will also need to take care of high-availability (what happens when your instance becomes unavailable?), scalability (what happens when one instance is not enough to sustain the load of your application?), load balancing and many more topics you'll need to address.
Finally, If you need to install packages on your application servers you may consider taking the Managed VMs route. It manages for you all the infrastructure related matters (scalability, elasticity, monitoring etc) and still allows you to have your own custom runtime. It's still beta though...
How to create a simple static Website and deploy it on Google cloud VM instance
Recommended: Docker and Google Cloud SDK should be installed
Step:1
Create a Folder “personal-website” with index.html and frontend files on your local computer
Step:2
Inside “personal-website” folder create a Dockerfile
Write two lines
FROM httpd
COPY . /usr/local/apache2/htdocs/personal-website
Step:3
Build image with docker and push it to Google cloud registry
You should have google cloud sdk and project selected and docker authorized
Select Project using these commands:
gcloud config set project [PROJECT_ID]
gcloud config set compute/zone us-central1-b
After that Run these commands
1. export PROJECT_ID="$(gcloud config get-value project -q)"
2. docker build -t gcr.io/${PROJECT_ID}/personal-website:v1 .
3. gcloud auth configure-docker
4. docker push gcr.io/${PROJECT_ID}/personal-website:v1
Step:4
Create a VM instance with command with container running into it
Run Command
1. gcloud compute instances create-with-container apache-vm2 --container-image gcr.io/test-project-220705/personal-website:v1