access the google compute server with a subdomain rather than external IP address - google-cloud-storage

I created a VM instance and deployed my application. I can access the application through the given external IP address, but I want to access it with some domain, just like openshift provides a domain AAA.rhcloud.com, which we can use the access the projects from the VM.
Is it possible to do it easily without normal DNS and CNAME route?
Thanks,
Manish

Most IP addresses have a DNS address than you can find out with reverse DNS:
$ dig +short -x 104.197.1.2
2.1.197.104.bc.googleusercontent.com.
As you can see on GCE you can reverse the IP address and append bc.googleusercontent.com. Of course this is no easier to remember than the IP address itself.
Between GCE instances in the same project, you can also use INSTANCE_NAME.c.PROJECT_ID.internal, but this won't work from outside GCE.

Related

Access ingress IP from a pod

I have got an authentication service. This service is behind an ingress (GKE in my case) for external API calls. When the signup function of the authentication service is called, it will send an email for email verification purpose. The link in this email has to point to the IP of ingress. In order to achieve that, my authentication service has to know the IP of the ingress. How can this be configured dynamically in k8s without storing the ingress IP[ address in a config file?
Many thanks in advance
Regards
Since by default GKE allocates ephemeral external IP address the simplest solution is to reserve static ip address. This can be done with new one or you can promote existing ephemeral IP to static one. With this solution the IP address is known in advance but the drawback of that the IP would have to be hardcoded into the application.
To avoid hardcoding this you could use nslookup to find ip address for this specific host. With this you should update your dns records with an address type record to point to you reserved static IP address. Please refer to your DNS service`s documentation on setting DNS A records to configure your domain name.
For more reading check how to configure static ip address.
The alternative way would be also to access the Kubernetes REST API directly and fetch the IP address from there. This depending on your architecture and application design will required appropriate authentication towards API.

GKE Kubernetes external domain provider

I built simple cluster in GKE with two services using this tutorial
https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app
After finishing that I'm able to access my service using external IP address. So I bought domain for using this IP address. After setup A record in DNS settings to that IP address, domain doesn't work, it still loads and then show ERR_CONNECTION_TIMED_OUT. Do I need to do something in google console, or how I can make this IP public and accessed through domain?
Please refer to official documentation, which describes steps you need to take to configure domain names with static IP.
There are steps that you need to cover:
Go to NETWORKING section at GCP console, than VPC Network -> External IP addresses to ensure that you are running static IP address, not ephemeral one.
Go to Network services -> Cloud DNS. You need to create DNS zone, where at DNS name line you have to wright your domain name. After creation you will see Add record set, where you need to paste your external IP address.
There is also a good tutorial at YouTube with setting up custom domain on GCP. Let me know if it works for you.

How to access REST APIs hosted locally on Alexa

I am developing a custom Alexa Skill and have a requirement where I want Alexa to access REST APIs that are hosted locally on http://localhost:8080? Any idea how to do this?
Thanks!
If you really want to do this, and I’m assuming you are hosting the skill on AWS Lambda, it would involve quite a bit of work.
Your local endpoints need to be accessible from outside of your network, which requires port forwarding in your router to your machine where the endpoints are hosted. This needs to be configured in your router.
An easier way is to deploy your project containing the API to something like Heroku, which can be done easily. They give you a domain and make the endpoints accessible to Lambda. This should be possible within their free tier.
Here' a link to a pretty good article about how IP addresses work.
Allowing a device sitting on your local network (eg. a laptop computer or Raspberry Pi connected to your wifi) to be accessed from outside your local network (eg. from a service running on AWS) will involve mapping 2 separate IP addresses:
The IP address assigned to your router (your public IP)
The private IP addresses assigned by your router to your devices (laptop, iPhone, RPi, etc).
You have a couple options for allowing your router's IP (#1) to be accessible from outside your local network:
a. Pay your internet provider to provide you with a static IP address
b. Use a dynamic DNS service such as DuckDNS or No-IP.
Once you have a fixed public IP that can be used to access your router, you will then need to map a port on your router (#1) to the device IP on your local network (#2). This is usually referred to as "port forwarding". Most routers will support configuring this. In effect, your tell your router "when you get a message to : pass it to my laptop :"
Your local private IP address will typically have an IP value like 192.168.0.23 (where the 23 can be anything from 1 to 254).
An outside IP will start with something other than 192. Refer to the first link above regarding IP ranges.
You can google "port forwarding" and "public IP" for more info on how IP addresses and port forwarding work, but hopefully this will help get you started. It may seem a bit complicated at first, but if I can understand it, then anyone can :-)

Website with dedicated IP Address, still uses shared server IP

Using cPanel WHM I have created a website hosting with Dedicated IP Address,
I'm planning to use it with the IP Address instead of a domain (e.g. http://1.2.3.4/script.php)
It opens, script also works fine.
The only issue is the IP address it uses isn't dedicated, it still uses server's shared IP.
I checked by CURL equivalent file_get_contents('http://myip.is') , the IP is the shared IP of server not the IP is use in URL or dedicated to it.
After a lot of tries, I realized the issue is because of CURL, apparently it still uses the server's main IP Address.
I managed to fixed this by adding the following to my CURL function
// Changing 1.2.3.4 with websites real IP
$website_ip = '1.2.3.4';
curl_setopt($curl, CURLOPT_INTERFACE, $website_ip);

Access external IP address from service

Is it possible to get the external IP address for a POD? It doesn't appear to be populating in the environmental variables for a service, so I was wondering if there was another way to get that information.
Basically: I'm setting up a proftpd service, and it needs to send out its external ip as well as a port for passive communication. Right now, it's sending the local IP address which is causing FTP clients to fail.
The kubernetes service discovery mechanism (DNS or environment variable) doesn't populate the external IP.
One way to work around is to create a static IP first, then assign it to your service.
Or you can exec kubectl inside your cluster to get the external IP but that's nasty.