Friday, February 24, 2017

Sunday, February 19, 2017

How to setup GKE?

I'm usually manage google cloud command in Postman.
Follow next orders.
  1. Create own network.
    curl -X POST -H "Content-Type: application/json" -H "Authorization: {{Your Access Token}}" -H "Cache-Control: no-cache" -d '{
      "name": "{{Your Network Name}}",
      "description": "{{Your Network Description}}",
      "autoCreateSubnetworks": false
    }' "https://www.googleapis.com/compute/v1/projects/{{Your Project ID}}/global/networks"
  2. Create subnetwork.
    curl -X POST -H "Content-Type: application/json" -H "Authorization: {{Your Access Token}}" -H "Cache-Control: no-cache" -d '{
      "ipCidrRange": "10.10.0.0/20",
      "name": "asia-east1",
      "network": "https://www.googleapis.com/compute/v1/projects/{{Your Project ID}}/global/networks/{{Your Network Name}}"
    }' "https://www.googleapis.com/compute/v1/projects/{{Your Project ID}}/regions/asia-east1/subnetworks"
  3. Create cluster in GKE.
    curl -X POST -H "Content-Type: application/json" -H "Authorization: {{Your Access Token}}" -H "Cache-Control: no-cache" -H "Postman-Token: bc7eddb2-be25-29f6-9af4-be948e1519b6" -d '{
      "cluster": {
        "name": "{{Your Cluster Name}}",
        "zone": "asia-east1-a",
        "network": "{{Your Network Name}},
        "loggingService": "logging.googleapis.com",
        "monitoringService": "none",
        "description": "{{Your Cluster Description}}",
        "subnetwork": "asia-east1",
        "nodePools": [
          {
            "initialNodeCount": 1,
            "config": {
              "machineType": "n1-standard-2",
              "imageType": "GCI",
              "diskSizeGb": 100,
              "localSsdCount": 1,
              "oauthScopes": [
                "https://www.googleapis.com/auth/compute",
                "https://www.googleapis.com/auth/devstorage.read_write",
                "https://www.googleapis.com/auth/bigquery",
                "https://www.googleapis.com/auth/sqlservice.admin",
                "https://www.googleapis.com/auth/datastore",
                "https://www.googleapis.com/auth/logging.write",
                "https://www.googleapis.com/auth/monitoring.write",
                "https://www.googleapis.com/auth/bigtable.data",
                "https://www.googleapis.com/auth/servicecontrol",
                "https://www.googleapis.com/auth/service.management.readonly",
                "https://www.googleapis.com/auth/trace.append"
              ]
            },
            "autoscaling": {
              "enabled": false
            },
            "management": {
              "autoUpgrade": false,
              "autoRepair": false,
              "upgradeOptions": {}
            },
            "name": "{{Your Pool Name}}"
          }
        ],
        "masterAuth": {
          "username": "admin"
        }
      }
    }' "https://container.googleapis.com/v1/projects/{{Your Project ID}}/zones/asia-east1-a/clusters"
  4. Get credential of cluster.
    gcloud container clusters list
    gcloud config set container/cluster {{Your Cluster Name}}
    gcloud config set compute/zone {{Your Zone ID}}
    echo "export GOOGLE_APPLICATION_CREDENTIALS={{Your Key File Address}}" >> ~/.bash_profile
    gcloud container clusters get-credentials {{Your Cluster Name}}

Wednesday, February 15, 2017

mysql data directory error on kubernetes.

If you meet next error...
[ERROR] --initialize specified but the data directory has files in it. Aborting.
You should add next argument in recipe.
spec:
  containers:
  - name: db-mysql
    image: mysql:5.7
    args: ["--ignore-db-dir=lost+found"]

Monday, February 13, 2017

Private docker registry on kubernete recipe

Encrypt docker config to base64.
cat ~/.docker/config.json | base64
Add encrypted data to data element.
apiVersion: v1
kind: Secret
metadata:
  name: docker-config
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: ewoJI...
Refer docker-config as same level with container in deployment.
imagePullSecrets:
  - name: docker-config

Sunday, February 12, 2017

Can't see console log of react native in nuclide.

Go to nuclide setting and change value of "Tag to include" to "^(.*)$" like this.

Friday, February 10, 2017

Connect to localhost inside docker

If your service inside docker want to connect to localhost, you can attach next option.
docker run --net="host"