I am learning Kubernetes on GCP
So far i have two deployments front end and backend as separate containers through separate deployment yaml files.
I am exposing them through service yaml files on port 8080 and 8081 respectively.
I can trigger the endpoints separately , however what should be the hostname/ ip address in the ajax call ?
When I do kubectl get services.
I get two different services with their own cluster ip and external ip , but external ip changes as I delete the service.
how can i use locahost:8081?querysearch in my ajax call
Found the answer.
I was trying something stupid , I had made my ui as a static frontend , hence the need for ajax calls to the backend.
I changed it by using a simple express server serving the requests , and a function inside would call the request to my backend
since the express server is inside the cluster , I was then able to access the backend with
http://service-name.default.svc.cluster.local:portname
Related
I'm using traefik v2 as gateway. I have a frontend container running with host https://some.site.com which powered by traefik.
Now I have a micro-service server with multi services and all of them are listening on 80 port. I want to serve the backend server on path https://some.site.com/api/service1, https://some.site.com/api/service2 ...
I have tried traefik.http.routers.service1.rule=(Host(some.site.com) && PathPrefix(/api/service1)) but not worked and traefik.http.middlewares.add-api.addprefix.prefix=/api/service1 not worked too;
How can I implement this?
Can you post your services' docker-compose configuration?
If you use middlewares, you may need to specify the service. Like
traefik.http.routers.service1.middlewares=add-api
traefik.http.middlewares.add-api.addprefix.prefix=/api/service1
Hello i would like to know how two micro-services can communicate with each other . Exemple:
I have a authentification service and a company service. I would like to set if you want to check the list of company's first you need to be authentificate by the authentification service.
This is my repo with all the services:
https://github.com/costelmarianmereuta/communication-services.git
Thank you in advance for your help
For internal API calls, you can directly hit the load balancer URL, appended with the API endpoint of the company service. Depending on your architecture you may have a separate load balancer for each microservice or a single load balancer might have multiple services running on it on different ports.
I could create some VM instances, add them to an instance group; also created an HTTP health check, and a backend service using gcloud command in a GCE project using these guides:
https://cloud.google.com/sdk/gcloud/reference/compute/http-health-checks/create
https://cloud.google.com/sdk/gcloud/reference/compute/backend-services/create
However, I can't find the doc to create a frontend service which is required to create a balancer, and indeed, the doc for creating balancer is also not available on Google Cloud SDK Reference.
Is it real no way to use gcloud command to create frontend service and balancer?
Found it, it's called forwarding-rules, not frontend-services, rather confusing.
And forwarding rule won't point directly to a backend-service. Forwarding rule (global) points to Target HTTP Proxy, and Target HTTP Proxy needs a URL Map.
Reference:
https://cloud.google.com/sdk/gcloud/reference/compute/forwarding-rules/create
Credit to the answer of #eSniff here:
https://stackoverflow.com/a/28533614/5581893
I'm building a small web application for a personal project. It will be an Angular web application which will talk to a Spring-Boot service layer which in turn will read/write stuff to MongoDb.
I hope to host all this on a single EC2 instance in AWS. My question is how to configure a web server (like Apache but doesn't have to be) to 'beautify' the URLs a bit. Example, without touching anything angular will run at something like host:4200 and the service layer at host:8080. I will then have to map a proper domain to host in AWS, but the hiding of ports etc is where it gets murky for me.
I want to be able to hit my web app at domain.com (no ports etc) and I also want my service layer to ideally have a similar setup e.g. domain.com/service (no ports etc).
How do I configure a webservice to do this for me? Examples or pointers to specific examples would be ideal, but even a pointer to the right documentation will be helpful.
This thread is kind of similar to what I want but not too helpful: How to deploy Spring framework backend and Angular 2 frontend application in any online server?
You can use a setup with AWS CloudFront as reverse proxy and CDN cache. You can map the Domain Name and SSL Certificates(You can use AWS issued free SSL Certificates through AWS Certificate Manager) to CloudFront while the EC2 instance is plugged as an origin behind CloudFront as shown in the following diagram.
In the diagram I have optionally added, which is a common practice in designing applications in AWS.
Hosting the Angular App in S3
Using Autoscaling & Loadbalancing for EC2 instances.
You need to use Apache or other web server as a reverse proxy. Start here -
https://devops.profitbricks.com/tutorials/configure-apache-as-a-reverse-proxy-using-mod_proxy-on-ubuntu/
You then will need to setup a custom domain name. The easiest option is to just use an ELB (now called Classic Load Balancer). More details are here -
http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/using-domain-names-with-elb.html
I have created locally stateless WebAPI and Statefull data service with the Visual Studio 2015. It is working perfectly in the local system and website access WebAPI service by implementing http://localhost:344/api/abc/getEmployee. Then I deployed service fabric application on Azure and received client URL
http://xyz.southeastasia.cloudapp.azure.com:1900/Explorer/index.html#/abc.apptype/app/abc.app/service/abc.app%252webservices
My problem is that how can I call my WebAPI controller and action from this Azure client URL?
http://xyz.southeastasia.cloudapp.azure.com:1900/api/abc/getEmployee is not working.
Note: This url is not secure and will use by mobile and website.
You're using the wrong port to access your application. Port 19000 is a Management endpoint.
Read this to setup your API. Run your app at port 80 (if possible),
Make sure that the Azure Load Balancer has a load balancing rule for port 80 external to port 80 on the cluster nodes. More info here.
You need to configure an inbound TCP rule for the port you want to use. Typically you will map an inbound port (such as port 80) to the port that your application is listening on (e.g. 344).
In the Azure management portal, find the resource group of your deployed Service Fabric service; in it, there should be a "Load Balancer" resource. -- Click on that.
In there, you should find a pane called "Load Balancing Rules" (it's easy to look past it with the light gray icon, it's right above "Inbound NAT Rules").
Using the button at the top of the configuration blade, "Add" a rule for the port that you need opened; You should give it a meaningful name (such as HTTP or WebAPI, etc.) -- for "Port" this is the publicly facing port that you want mapped (e.g. port 80 for HTTP), and for Backend port, you can put the port that you're actually listening on (e.g. 344).
Finally, don't expect it to work right away. -- You will see a little "Updating" bar, you have to wait for that to finish.