|
| 1 | +# First we create a project namespace |
| 2 | +kubectl create ns project-x |
| 3 | + |
| 4 | +# Now we install navigator in that namespace |
| 5 | +helm \ |
| 6 | + --debug \ |
| 7 | + install \ |
| 8 | + --wait \ |
| 9 | + --name navigator \ |
| 10 | + --namespace project-x \ |
| 11 | + --set apiserver.image.repository=gcr.io/jetstack-sandbox/navigator-apiserver \ |
| 12 | + --set controller.image.repository=gcr.io/jetstack-sandbox/navigator-controller \ |
| 13 | + contrib/charts/navigator |
| 14 | + |
| 15 | +# Let's see what's been installed |
| 16 | +kubectl get all --namespace project-x |
| 17 | +kubectl get clusterrolebinding --namespace project-x | grep navigator |
| 18 | + |
| 19 | +# And let's take a look at the Navigator logs |
| 20 | +# First the apiserver logs |
| 21 | +kubectl --namespace project-x logs -c apiserver deploy/navigator-navigator-apiserver |
| 22 | + |
| 23 | +# And then the controller logs |
| 24 | +kubectl --namespace project-x logs deploy/navigator-navigator-controller |
| 25 | + |
| 26 | +# Now that Navigator is running we can start a Cassandra single node cluster, using Helm. |
| 27 | +helm install \ |
| 28 | + --debug \ |
| 29 | + --wait \ |
| 30 | + --name "cc-1" \ |
| 31 | + --namespace "project-x" \ |
| 32 | + --set pilotImage.repository=gcr.io/jetstack-sandbox/navigator-pilot-cassandra \ |
| 33 | + --set replicaCount=1 \ |
| 34 | + contrib/charts/cassandra |
| 35 | + |
| 36 | +# Let's take a quick look at the CassandraCluster resource |
| 37 | +kubectl --namespace project-x get cassandraclusters --output yaml |
| 38 | + |
| 39 | +# And let's see what other resources have been created |
| 40 | +kubectl --namespace project-x get all |
| 41 | + |
| 42 | +# We can look at the cassandra database logs |
| 43 | +kubectl --namespace project-x logs statefulsets/cass-cc-1-cassandra-ringnodes |
| 44 | + |
| 45 | +# Now we'll connect to Cassandra and run some queries |
| 46 | +# (We'll use telepresence to allow us to run cqlsh as if we are in the project-x namespace) |
| 47 | +telepresence --run-shell --namespace project-x |
| 48 | + |
| 49 | +# There's a service which loadbalances CQL connections between all the Cassandra nodes. |
| 50 | +cqlsh --cqlversion=3.4.2 cass-cc-1-cassandra-cql 9042 |
| 51 | + |
| 52 | +TRACING ON |
| 53 | +SHOW VERSION |
| 54 | +SHOW HOST |
| 55 | +DESCRIBE CLUSTER |
| 56 | + |
| 57 | +# Now let's scale up the cluster |
| 58 | +# We use Helm to increment the replica count |
| 59 | +helm upgrade \ |
| 60 | + --debug \ |
| 61 | + "cc-1" \ |
| 62 | + contrib/charts/cassandra \ |
| 63 | + --set pilotImage.repository=gcr.io/jetstack-sandbox/navigator-pilot-cassandra \ |
| 64 | + --set replicaCount=2 |
| 65 | + |
| 66 | +# Run the node tool to see the cluster status |
| 67 | +kubectl --namespace project-x exec cass-cc-1-cassandra-ringnodes-0 -- nodetool status |
| 68 | + |
| 69 | + |
| 70 | +-- Database example is copied from: |
| 71 | +-- http://blog.mclaughlinsoftware.com/2017/07/30/cassandra-query-language/ |
| 72 | +-- Create a database |
| 73 | +DROP KEYSPACE IF EXISTS student; |
| 74 | + |
| 75 | +CREATE KEYSPACE IF NOT EXISTS student |
| 76 | + WITH REPLICATION = { |
| 77 | + 'class':'SimpleStrategy' |
| 78 | + ,'replication_factor': 2 } |
| 79 | + AND DURABLE_WRITES = true; |
| 80 | + |
| 81 | +USE student; |
| 82 | + |
| 83 | +-- See the ranges distributed to both nodes |
| 84 | +DESCRIBE CLUSTER |
| 85 | + |
| 86 | +-- Create some data |
| 87 | +CONSISTENCY ALL |
| 88 | + |
| 89 | +DROP TABLE IF EXISTS member; |
| 90 | + |
| 91 | +CREATE TABLE member |
| 92 | +( member_number VARCHAR |
| 93 | +, member_type VARCHAR |
| 94 | +, credit_card_number VARCHAR |
| 95 | +, credit_card_type VARCHAR |
| 96 | +, PRIMARY KEY ( member_number )); |
| 97 | + |
| 98 | +DROP TABLE IF EXISTS contact; |
| 99 | + |
| 100 | +CREATE TABLE contact |
| 101 | +( contact_number VARCHAR |
| 102 | +, contact_type VARCHAR |
| 103 | +, first_name VARCHAR |
| 104 | +, middle_name VARCHAR |
| 105 | +, last_name VARCHAR |
| 106 | +, member_number VARCHAR |
| 107 | +, PRIMARY KEY ( contact_number )); |
| 108 | + |
| 109 | +INSERT INTO member |
| 110 | +( member_number, member_type, credit_card_number, credit_card_type ) |
| 111 | +VALUES |
| 112 | +('SFO-12345','GROUP','2222-4444-5555-6666','VISA'); |
| 113 | + |
| 114 | +INSERT INTO contact |
| 115 | +( contact_number, contact_type, first_name, middle_name, last_name, member_number ) |
| 116 | +VALUES |
| 117 | +('CUS_00001','FAMILY','Barry', NULL,'Allen','SFO-12345'); |
| 118 | + |
| 119 | +INSERT INTO contact |
| 120 | +( contact_number, contact_type, first_name, middle_name, last_name, member_number ) |
| 121 | +VALUES |
| 122 | +('CUS_00002','FAMILY','Iris', NULL,'West-Allen','SFO-12345'); |
| 123 | + |
| 124 | +INSERT INTO member |
| 125 | +( member_number, member_type, credit_card_number, credit_card_type ) |
| 126 | +VALUES |
| 127 | +('SFO-12346','GROUP','3333-8888-9999-2222','VISA'); |
| 128 | + |
| 129 | +INSERT INTO contact |
| 130 | +( contact_number, contact_type, first_name, middle_name, last_name, member_number ) |
| 131 | +VALUES |
| 132 | +('CUS_00003','FAMILY','Caitlin','Marie','Snow','SFO-12346'); |
| 133 | + |
| 134 | +SELECT * FROM member; |
| 135 | + |
| 136 | +# We can simulate an unresponsive node and see how the Readiness and Liveness probes detect the problem and restart the node. |
| 137 | +# Stop one of the cassandra processes. |
| 138 | +kubectl --namespace project-x exec cass-cc-1-cassandra-ringnodes-0 -- bash -c 'kill -SIGSTOP -- $(ps -u cassandra -o pid=)' |
| 139 | + |
| 140 | +# Nodetool now reports a node Down |
| 141 | +kubectl --namespace project-x exec cass-cc-1-cassandra-ringnodes-1 -- nodetool status |
| 142 | + |
| 143 | +# And kubernetes reports that one of the pods is "unready" |
| 144 | +kubectl --namespace project-x get pods |
| 145 | + |
| 146 | +# Cleanup |
| 147 | +helm delete --purge cc-1 navigator |
| 148 | +kubectl delete ns --now project-x |
0 commit comments