Posts

Showing posts with the label kubernetes

Using Visual Studio Code to Edit Files in Openshift Pods

Image
Tracing PHP applications are typically done by putting echo statements in code path in a debug session. When PHP applications are deployed into openshift environment, the developer could edit the source code in development app (not production) to add echo statements. Typically this is done using the terminal. However the development experience is not very good. Background When debugging or tracing, we developers sometimes need to check multiple files at once, and sometimes need to do a project-wide search to find the source file containing one class or method. Most developers find this is not easy to do  in the terminal interface. They normally use editors such as Visual Studio Code to be able to search quickly and jump between source code files, and using vi in the terminal is somewhat off-putting. A better solution is to run Visual Studio Code remotely in the pod's container. How to Launch Visual Studio Code in Pods There are a few prerequisite needed to be able to launch vi...

Notes on Learning Open VSwitch in Openshift OKD

Background Open VSwitch or ovs is the software that openshift used to ensure pods in the openshift cluster could talk to each other using cluster-internal IP addresses. In default settings, hosts outside the cluster are not be able to connect directly to pods; and haproxy (running in  'openshift router' pods) sofware listening on host port is doing the work of distributing http request into each and every application's pods.  In order to follow this blog post you will need root-level OS access on the hosts / openshift nodes, so it is geared towards system administrator of the openshift platform, not the casual application developer. Examining OVS bridge [root@node3 ~]# ovs-vsctl list-br br0 So we know the OVS bridge is named br0. [root@node1 ~]# ovs-ofctl -O OpenFlow13 dump-ports-desc br0 OFPST_PORT_DESC reply (OF1.3) (xid=0x2):  1(vxlan0): addr:62:b2:af:23:90:ea      config:     0      state:      0   ...

Backing Up MySQL Database using Openshift/Kubernetes Cron Job

Periodic Backups When running an application in production, the data and app should be backed up periodically. One way to do that is by using git repository for the source code and periodically dumping the database. This article shows how to do such periodic jobs using CronJob functionality of Openshift/Kubernetes. Technique When running a cronjob, the filesystem that being used to run the  pod will be ephemeral, that is, non-persistent. To work around this limit we should mount from external volume, which can be in the form of persistent volume claim or directly provided volume specification.  The Job specs apiVersion: batch/v1 kind: Job metadata:   name: job04-test  spec:   template:     spec:       containers:       - name: job04c-test         image: centos/mysql-57-centos7         command: ["/bin/sh","-c",  "/opt/rh/rh-mysql57/root/usr/bin/mysqldump ...