Skip to main content

Featured post

How to Insert line break in Text component in React Native

Hi, I was developing an application in react native.I have to handle lots of text data in this small react native application.I have used  Text component in react native many times. While working on this application,i had a requirement to display some text content with line breaks.I will explain it clearly with an example.I want to display a text as shown below  Welcome Please subscribe my channel I wrote react native code as shown below <View> <Text> Welcome Please subscribe my channel </Text> <View> When i run these lines of code,It will display text as shown below Welcome Please subscribe my channel   - instead of displaying in two lines with line break,it displays in a single line.So i have to find a solution to insert line break in Text component in React Native.After lots of research,i found a clean solution as shown below <View> <Text> Welcome{"\n"} Please subscribe my channel </Text> <View> Here ...

How to Connect External MySQL Server Database from Inside Kubernetes Cluster -Nodes Containers Pods Docker Images Running Node.JS -JavaScript TypeScript Applications -YAML File

Last two weeks ,I was trying to access MySQL Database  running in my local machine (It is in localhost with port number 3306)  from inside Kubernetes Cluster. Nodes -Containers-Pods-running Docker images which is in  Node JS  


I could not find anything which can help me to access external database  from Kubernetes clusters

I tried with a YAML file which did not help me 

After lots of  research finally I could connect my  External MySQL Database from inside Kubernetes with  below yaml file.






Service and Endpoints as given below helped me to connect MySQL Database running in IP Address 192.168.0.100 (IP address of  local machine running MySQL Database)  and Port number 3306


auth-db-srv.yaml






apiVersionv1
kindService
metadata:
  nameauth-db 
spec:
  ports:
    - protocolTCP
      port3306
      targetPort3306
---
apiVersionv1
kindEndpoints
metadata:
  nameauth-db 
subsets:
  - addresses:
      - ip192.168.0.100
    ports:
      - port3306





db.ts 





const mysql = require("mysql");

const con = mysql.createConnection({
  host: "auth-db",
  user: "root",
  password: "root",
  database: "auth",
  port: 3306,
  multipleStatements: true
});

con.connect(function (error:any) {
  if (!!errorconsole.log(error);
  else console.log("Database Connected!");
});
export {con}