<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Cybermaze on Medium]]></title>
        <description><![CDATA[Stories by Cybermaze on Medium]]></description>
        <link>https://medium.com/@cybermaze?source=rss-fb2df58c9c5a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Hqm3ieHSdBZZ0mEN</url>
            <title>Stories by Cybermaze on Medium</title>
            <link>https://medium.com/@cybermaze?source=rss-fb2df58c9c5a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:30:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cybermaze/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Qwiklabs: Secure Workloads in Google Kubernetes Engine: Challenge Lab]]></title>
            <link>https://medium.com/@cybermaze/qwiklabs-secure-workloads-in-google-kubernetes-engine-challenge-lab-5ad135b4fffe?source=rss-fb2df58c9c5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ad135b4fffe</guid>
            <category><![CDATA[qwiklabs-challenge-lab]]></category>
            <category><![CDATA[qwiklabs]]></category>
            <dc:creator><![CDATA[Cybermaze]]></dc:creator>
            <pubDate>Fri, 13 Nov 2020 17:54:09 GMT</pubDate>
            <atom:updated>2020-11-13T17:54:09.967Z</atom:updated>
            <content:encoded><![CDATA[<h3>Challenge scenario</h3><p>As a newly trained Kubernetes engineer in Jooli Inc. you have been asked to demonstrate to the security team features to protect Kubernetes workloads.</p><p>You are expected to have the skills and knowledge for these tasks so don’t expect step-by-step guides.</p><p>Some Jooli Inc. standards you should follow:</p><ul><li>Create all resources in the us-east1 region and us-east1-b zone, unless otherwise directed.</li><li>Use the project VPCs.</li><li>Naming is normally <em>team-resource</em>, e.g. an instance could be named <strong>kraken-webserver1</strong>.</li><li>Allocate cost effective resource sizes. Projects are monitored and excessive resource use will result in the containing project’s termination (and possibly yours), so beware. This is the guidance the monitoring team is willing to share: unless directed, use n1-standard-1.</li></ul><h3>Your challenge</h3><p>You need to secure a WordPress running on GKE that uses Cloud SQL as it’s database.</p><p>During the training you spoke to the instructor who emailed you a list of tasks they thought you should do in your demonstration. This is the contents of the email.</p><h3>Task 0: Download the necessary files</h3><ol><li>Open Cloud Shell and run the following to collect all the files made available to you:</li></ol><pre>gsutil -m cp gs://cloud-training/gsp335/* .</pre><h3>Task 1: Setup Cluster</h3><p>To create a cluster for your demo, use the following values to ensure you have enough resources:</p><ul><li>zone: us-central1-c</li><li>machine-type: standard-4</li><li>nodes: 2</li><li>Enable network policy</li></ul><pre>gcloud container clusters create kraken-cluster --zone us-central1-c --machine-type n1-standard-4 --num-nodes 2 --enable-network-policy</pre><h3>Task 2: Setup WordPress</h3><p>If you have not setup WordPress using Cloud SQL before, here are some general steps for you here:</p><h4>Setup the Cloud SQL database and database username and password</h4><p>2. Create a Cloud SQL instance in us-central1, using the default values.</p><pre>gcloud sql instances create kraken-sql --region=us-central1 --root-password=1234</pre><p>3. Create a Cloud SQL database for WordPress.</p><pre>gcloud sql databases create wordpress --instance=kraken-sql</pre><p>4. Create a user using the following values:</p><ul><li>Access from host %</li><li>Access to the Cloud SQL instance you created</li><li>Set a password (remember it, you will need later)</li></ul><pre>gcloud sql users create wordpress --instance=kraken-sql --host=% --password=password</pre><pre>gcloud sql users create user --instance=kraken-sql --host=% --password=password</pre><h4>Create a service account for access to your WordPress database from your WordPress instances</h4><p>5. Create the service account.</p><pre>MYPROJECT=$(gcloud config list --format &#39;value(core.project)&#39;)</pre><pre>gcloud iam service-accounts create kraken-service</pre><p>6. Bind the service account to your project, give the role roles/cloudsql.client.</p><pre>gcloud projects add-iam-policy-binding ${MYPROJECT} \<br>    --member=&quot;serviceAccount:kraken-service@${MYPROJECT}.iam.gserviceaccount.com&quot; \<br>    --role=&quot;roles/cloudsql.client&quot;</pre><p>7. Save the service account credentials in a json file.</p><pre>gcloud iam service-accounts keys create key.json --iam-account=kraken-service@${MYPROJECT}.iam.gserviceaccount.com</pre><p>8. Save the service account json file as a secret in your Kubernetes cluster.</p><p>Use this as a template:</p><pre>kubectl create secret generic cloudsql-instance-credentials --from-file key.json</pre><p>9. Save the WordPress database username and password as secrets in your Kubernetes cluster.</p><p>Use this as a template:</p><pre>kubectl create secret generic cloudsql-db-credentials \<br>    --from-literal username=wordpress \<br>    --from-literal password=&#39;1234&#39;</pre><h4>Create the WordPress deployment and service</h4><p>10. Use kubectl create -f volume.yaml to create a persistent volume for your WordPress application.</p><pre>kubectl create -f volume.yaml</pre><p>11. Open wordpress.yaml and replace <strong>INSTANCE_CONNECTION_NAME</strong> with the instance name of your Cloud SQL database (the format is <em>project:region:databasename</em>).</p><pre>sed -i &quot;s/INSTANCE_CONNECTION_NAME/${MYPROJECT}:us-central1:kraken-sql/g&quot; wordpress.yaml</pre><p>12. Use kubectl apply -f wordpress.yaml to create the WordPress environment.</p><pre>kubectl apply -f wordpress.yaml</pre><h3>Task 3: Setup Ingress with TLS</h3><h4>Set up nginx-ingress environment</h4><p>13. Make sure you add and update the stable repo for helm.</p><pre>helm repo add stable <a href="https://charts.helm.sh/stable">https://charts.helm.sh/stable</a><br>helm repo update</pre><p>14. Install stable nginx-ingress (call it nginx-ingress).</p><pre>helm install nginx-ingress stable/nginx-ingress</pre><h4>Set up your DNS record</h4><p>15. Check the service nginx-ingress-controller as an external IP address before continuing (kubectl get svc) to the next step.</p><pre>kubectl get service nginx-ingress-controller</pre><p>16. Run the command . add_ip.sh. You should see record added. You now have a DNS record added of the format YOUR_LAB_USERNAME.labdns.xyz which points to your ingress cluster (the script will output your DNS name).</p><pre>. add_ip.sh</pre><h4>Set up cert-manager.io</h4><p>17. Install cert-manager.io (make sure you use the right version).</p><pre>kubectl apply --validate=false -f <a href="https://github.com/jetstack/cert-manager/releases/download/v0.16.0/cert-manager.yaml">https://github.com/jetstack/cert-manager/releases/download/v0.16.0/cert-manager.yaml</a></pre><p>18. Edit issuer.yaml and set the email address to your email address.</p><pre>sed -i &quot;s/LAB_EMAIL_ADDRESS/kraken-service@${MYPROJECT}.iam.gserviceaccount.com/g&quot; issuer.yaml</pre><p>19. Use kubectl apply -f issuer.yaml to setup the letsencrypt prod issuer.</p><pre>kubectl apply -f issuer.yaml</pre><h4>Configure nginx-ingress to use an encrypted certificate for your site</h4><p>20. Edit ingress.yaml and set the dns and domain name to your YOURLABUSERNAME.labdns.xyz.(without underscores or hyphens)</p><pre>sed -i &quot;s/HOST_NAME/[YOURLABUSERNAME].labdns.xyz/g&quot; ingress.yaml</pre><p>21. Use kubectl apply -f ingress.yaml.</p><pre>kubectl apply -f ingress.yaml</pre><h3>Task 4: Set up Network Policy</h3><p>22. Show your colleagues how to restrict the network traffic using the provided network-policy.yaml file. It&#39;s not complete; you will need to add the configuration to allow ingress traffic from the world into nginx-ingress, but you can solve that easily.</p><p>Add following to the end of file.</p><pre>---<br>apiVersion: networking.k8s.io/v1<br>kind: NetworkPolicy<br>metadata:<br>  name: allow-nginx-access-to-internet<br>spec:<br>  podSelector:<br>    matchLabels:<br>      app: nginx-ingress<br>  policyTypes:<br>  - Ingress<br>  ingress:<br>  - {}</pre><h3>Task 5: Setup Binary Authorization</h3><p>23. Show your colleagues how to configure Binary Authorization to only allow the following images in your cluster:</p><p>Kubernetes Engine &gt; Clusters &gt; Edit &gt; Binary Authorization: Enable</p><p>Security &gt; Binary Authorization &gt; Configure Policy Disallow all images</p><p>Add following image paths</p><ul><li>docker.io/library/wordpress:latest</li><li>us.gcr.io/k8s-artifacts-prod/ingress-nginx/*</li><li>gcr.io/cloudsql-docker/*</li><li>quay.io/jetstack/*</li></ul><h3>Task 6: Setup Pod Security Policy</h3><p>24. Some Pod Security Policy demo files have been provided for you to use in your demo. They will forbid the use of the root user and prevent the mounting of the host filesystem within a container.</p><p>Remember to check the restrictions using a service account that has the role roles/container.developer as this will simulate a typical developer.</p><pre>sed -i &quot;s|extensions/v1beta1|extension/v1beta1|g&quot; psp-restrictive.yaml</pre><pre>kubectl apply -f psp-role.yaml<br>kubectl apply -f psp-use.yaml<br>kubectl apply -f psp-restrictive.yaml</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ad135b4fffe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>