production on davidchua https://dchua.com/tags/production/ Recent content in production on davidchua Hugo -- gohugo.io en-us Fri, 21 Apr 2017 00:00:00 +0000 Load env variables from ConfigMaps and Secrets upon Pod boot https://dchua.com/posts/2017-04-21-load-env-variables-from-configmaps-and-secrets-upon-pod-boot/ Fri, 21 Apr 2017 00:00:00 +0000 https://dchua.com/posts/2017-04-21-load-env-variables-from-configmaps-and-secrets-upon-pod-boot/ One of the coolest stuff I’ve picked up just today is that you can keep environment variables that you want to be loaded into every deployment pod in a neatly configured ConfigMap or Secret which gets injected back into the Pod during deploys. Lets say you have a Secret that looks like: apiVersion: v1 kind: Secret metadata: name: mysecret type: Opaque data: username: YWRtaW4= password: MWYyZDFlMmU2N2Rm And you want username and password to be easily accessible in ENV['username'] and ENV['password'] on your application pods, all you need is a envFrom within your TemplateSpec Supercharge your Nginx with Openresty and Lua https://dchua.com/posts/2017-01-01-supercharge-your-nginx-with-openresty-and-lua/ Sun, 01 Jan 2017 00:00:00 +0000 https://dchua.com/posts/2017-01-01-supercharge-your-nginx-with-openresty-and-lua/ Turn your Nginx into an API Gateway. Modify requests and responses from Nginx itself using Openresty and Lua. Objectives To deploy Openresty on a development/production environment As a reverse proxy, to modify incoming request params and pass it on to another server As a reverse proxy, to modify response from proxied server before returning to user Openresty Openresty is a open-sourced NGINX bundle that combines NGINX and various 3rd-party NGINX modules and Lua Libraries. Building a Kubernetes PetSet Cluster for your MongoDB ReplicaSet https://dchua.com/posts/2016-08-08-building-a-kubernetes-petset-cluster-for-your-mongodb-replicaset/ Mon, 08 Aug 2016 00:00:00 +0000 https://dchua.com/posts/2016-08-08-building-a-kubernetes-petset-cluster-for-your-mongodb-replicaset/ Some observations when working with Kubernetes 1.3 introduced PetSets to build MongoDB. Here’s my PetSet YAML: # mypetset.yml apiVersion: v1 kind: Service metadata: annotations: service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" name: a-mongo labels: name: a-mongo tier: database type: mongo spec: ports: - port: 27017 name: mongo type: NodePort selector: tier: database name: a-mongo --- apiVersion: apps/v1alpha1 kind: PetSet metadata: name: a-mongo spec: serviceName: "a-mongo" replicas: 3 template: metadata: labels: name: a-mongo tier: database annotations: pod. How to setup Fluentd to Log to S3 with Rails https://dchua.com/posts/2014-11-25-how-to-setup-fluentd-to-log-to-s3/ Tue, 25 Nov 2014 00:00:00 +0000 https://dchua.com/posts/2014-11-25-how-to-setup-fluentd-to-log-to-s3/ Logging is important. When you’re running a fully fledge production application server, you do not have the luxury of monitoring your rails console all the time. In this example, I will go through with you the process of setting up Fluentd with your Rails App to log data and to upload them onto S3 for persistent archival purposes. Pre-requsite Running Trusty (14.04) Ruby 2.1.2 installed An AWS Account with your AWS Credentials (key and token) ready Step 1: Download Td-Agent Wait, isn’t this a Fluentd tutorial? MySQL backup process https://dchua.com/posts/2014-08-28-mysql-backup-process/ Thu, 28 Aug 2014 00:00:00 +0000 https://dchua.com/posts/2014-08-28-mysql-backup-process/ How I usually prepare the backup regime of my mysql/mariadb databases of all my newly provisioned servers is to do the following tasks: Create a DBA user > create user 'dba'@'localhost'; Give the DBA user only the relevant access just for backing > GRANT SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'dba'@'localhost'; > GRANT LOCK TABLES ON *.* TO 'dba'@'localhost'; > FLUSH PRIVILEGES; Setup a backup script!