<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Victoria Santana</title>
    <description>The latest articles on DEV Community by Victoria Santana (@victoriasantana97).</description>
    <link>https://dev.to/victoriasantana97</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F567177%2F8ea6d5e1-46aa-4e88-a6ba-42f505f17bc2.jpeg</url>
      <title>DEV Community: Victoria Santana</title>
      <link>https://dev.to/victoriasantana97</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/victoriasantana97"/>
    <language>en</language>
    <item>
      <title>giving and taking permissions on postgres</title>
      <dc:creator>Victoria Santana</dc:creator>
      <pubDate>Mon, 15 Feb 2021 21:35:50 +0000</pubDate>
      <link>https://dev.to/victoriasantana97/giving-and-taking-permissions-on-postgres-4n45</link>
      <guid>https://dev.to/victoriasantana97/giving-and-taking-permissions-on-postgres-4n45</guid>
      <description>&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;I'm writing a short and handy guide to anyone in a jr position - especially if you are a junior sysadmin. I often find myself having to search for a specific command to do something basic. I'm fully aware there are tons of other tutorials/posts, but I hope you find this one clear and helpful. &lt;/p&gt;

&lt;h1&gt;
  
  
  Privileges
&lt;/h1&gt;

&lt;p&gt;Postgres offers 12 types of privileges, they are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SELECT&lt;/li&gt;
&lt;li&gt;INSERT&lt;/li&gt;
&lt;li&gt;UPDATE&lt;/li&gt;
&lt;li&gt;DELETE&lt;/li&gt;
&lt;li&gt;TRUNCATE&lt;/li&gt;
&lt;li&gt;REFERENCES&lt;/li&gt;
&lt;li&gt;TRIGGER&lt;/li&gt;
&lt;li&gt;CREATE&lt;/li&gt;
&lt;li&gt;CONNECT&lt;/li&gt;
&lt;li&gt;TEMPORARY&lt;/li&gt;
&lt;li&gt;EXECUTE&lt;/li&gt;
&lt;li&gt;USAGE&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Commands
&lt;/h1&gt;

&lt;p&gt;This are some examples based on what I use most in my day-to-day as an infrastructure analyst.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To give all privileges in a database for some user&lt;br&gt;
&lt;code&gt;GRANT ALL PRIVILEGES IN your_database TO your_user;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To let an user login&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;GRANT CONNECT ON DATABASE your_database TO your_user;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To become a superuser&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;ALTER USER your_user WITH SUPERUSER;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To let a user create databases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;ALTER USER your_user CREATEDB;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Giving permissions in a schema
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GRANT USAGE ON SCHEMA schema_name TO your_user;
GRANT SELECT, INSERT ON ALL TABLES IN SCHEMA schema_name TO username; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Giving permissions in a specific table &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;GRANT  { SELECT | INSERT | UPDATE | REFERENCES } ON TABLE table_name TO your_user&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This one is for giving permissions in all schemas of a database (there are other ways to do this)&lt;br&gt;
&lt;code&gt;SELECT format('GRANT USAGE ON SCHEMA %I TO readonly_group;', schema_name) FROM information_schema.schemata \gexec&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This one gives permissions on all tables in all schemas (again, there are other ways to do this)&lt;br&gt;
&lt;code&gt;SELECT format('GRANT SELECT ON ALL TABLES IN SCHEMA %I TO readonly_group;', schema_name) FROM information_schema.schemata \gexec&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Taking privileges
&lt;/h1&gt;

&lt;p&gt;First of all I'll show you how to remove privilege from a superuser&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ALTER USER username WITH NOSUPERUSER;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The command &lt;code&gt;REVOKE&lt;/code&gt; is used with similar syntax as &lt;code&gt;GRANT&lt;/code&gt;, only difference is that it &lt;em&gt;revokes&lt;/em&gt; privileges.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Removing user from role/group &lt;br&gt;
&lt;code&gt;REVOKE role FROM user;&lt;/code&gt; or &lt;code&gt;ALTER GROUP group DROP USER user;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Removing all privileges from a user&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;REVOKE ALL PRIVILEGES ON table FROM user;&lt;/code&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This is an alive document and I'm open to criticism, i'll probably update this with new findings.&lt;/p&gt;

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;p&gt;Here is a full guide with all PostgreSQL Commands (a.k.a documentation) - &lt;a href="https://www.postgresql.org/docs/13/sql-commands.html"&gt;https://www.postgresql.org/docs/13/sql-commands.html&lt;/a&gt; &lt;/p&gt;

</description>
      <category>postgres</category>
      <category>todayilearned</category>
      <category>database</category>
    </item>
    <item>
      <title>How to get grafana password kube-stack-prometheus</title>
      <dc:creator>Victoria Santana</dc:creator>
      <pubDate>Tue, 26 Jan 2021 17:07:56 +0000</pubDate>
      <link>https://dev.to/victoriasantana97/how-to-get-grafana-password-kube-stack-prometheus-41e0</link>
      <guid>https://dev.to/victoriasantana97/how-to-get-grafana-password-kube-stack-prometheus-41e0</guid>
      <description>&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;The helm repo kube-stack-prometheus (formerly prometheus-operator) comes with a grafana deployment embedded. In order to log in Grafana first you need to get the credentials (admin/admin didn't work for me).&lt;/p&gt;

&lt;h1&gt;
  
  
  Discovering the password 🔍
&lt;/h1&gt;

&lt;p&gt;The user is &lt;code&gt;admin&lt;/code&gt; and the password can be found with the following command &lt;code&gt;kubectl get secret grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I found the command looking into some github issues and I took me some time, so I hope this is useful to someone else.&lt;/p&gt;

&lt;h1&gt;
  
  
  Reference
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/prometheus-operator/prometheus-operator/issues/956"&gt;GitHub Thread&lt;/a&gt;&lt;/p&gt;

</description>
      <category>monitoring</category>
      <category>grafana</category>
      <category>todayilearned</category>
      <category>todayisearched</category>
    </item>
    <item>
      <title>creating a local monitoring environment with helm</title>
      <dc:creator>Victoria Santana</dc:creator>
      <pubDate>Mon, 25 Jan 2021 20:56:22 +0000</pubDate>
      <link>https://dev.to/victoriasantana97/creating-a-local-monitoring-environment-with-helm-4in</link>
      <guid>https://dev.to/victoriasantana97/creating-a-local-monitoring-environment-with-helm-4in</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;In this post, that is actually documentation for myself, I'll guide you thru the deployment of a monitoring environment in your local machine, this can be used for study and prototype. The project will use prometheus to monitor and grafana to plot graphs.&lt;/p&gt;

&lt;h1&gt;
  
  
  Getting your machine ready
&lt;/h1&gt;

&lt;p&gt;I'm using Ubuntu 20.04.1 LTS as my OS&lt;/p&gt;

&lt;p&gt;First you'll need to install a tool to run Kubernetes locally (kind, minikube, k3s or other that you like; Personally I use kind)&lt;/p&gt;

&lt;p&gt;The steps are the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$wget https://github.com/kubernetes-sigs/kind/releases/download/v0.8.1/kind-linux-amd64
$chmod +x kind-linux-amd64
$mv kind-linux-amd64 /usr/local/bin/kind
$kind version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then install Helm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo snap install helm --classic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for other ways of installing helm please refer to &lt;a href="https://helm.sh/docs/intro/install/"&gt;Helm Documentation&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Kind
&lt;/h1&gt;

&lt;p&gt;Now that we have our tools installed we need to create a kubernetes cluster &lt;/p&gt;

&lt;p&gt;&lt;code&gt;kind create cluster --name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you don't put the flag &lt;code&gt;--name&lt;/code&gt; the cluster name will be "kind"&lt;/p&gt;

&lt;h1&gt;
  
  
  Helm
&lt;/h1&gt;

&lt;p&gt;Helm is a package manager for Kubernetes&lt;/p&gt;

&lt;p&gt;To Add the prometheus charts repo use the command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;helm repo add prometheus-community https://prometheus-community.github.io/helm-charts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We'll install two helm charts&lt;/p&gt;

&lt;h4&gt;
  
  
  kube-prometheus-stack
&lt;/h4&gt;

&lt;p&gt;As per &lt;a href="https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack"&gt;github&lt;/a&gt; This chart contains a collection of Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;helm install prometheus-community/kube-prometheus-stack --generate-name&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  pushgateway
&lt;/h4&gt;

&lt;p&gt;Pushgateway is a tool that pushes metrics that cannot be scraped&lt;/p&gt;

&lt;p&gt;&lt;code&gt;helm install prometheus-community/prometheus-pushgateway --generate-name&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Testing and Tweaking
&lt;/h1&gt;

&lt;p&gt;Run &lt;code&gt;kubectl get services&lt;/code&gt; to see the services running and some information about them. A detail when deploying prometheus localy is to change the type of the following services &lt;code&gt;kube-prometheus-stack-1611-operator&lt;/code&gt; &lt;code&gt;kube-prometheus-stack-1611575778-grafana&lt;/code&gt; from ClusterIP to NodePort (if you are deploying it in a cloud environment you shall change to LoadBalancer). More information about Kubernetes services can be found &lt;a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To edit the services use the following command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl edit svc your-service-goes-here&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;this command will open a vim type editor and allow you to edit information about the service&lt;/p&gt;

&lt;p&gt;Now all you have to do is expose the ports using the port-forward command, the following example allows me to access alert-manager via browser&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl port-forward svc/alertmanager-operated 9093&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The syntax is kubectl port-forward TYPE/NAME PORT.&lt;/p&gt;

&lt;p&gt;And that's all for today 🤓&lt;/p&gt;

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack"&gt;Kube Prometheus Stack&lt;/a&gt;&lt;br&gt;
&lt;a href="https://helm.sh/docs/"&gt;Helm Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://kind.sigs.k8s.io/docs/user/quick-start/"&gt;Kind Quick Start&lt;/a&gt;&lt;br&gt;
&lt;a href="https://prometheus.io/docs/practices/pushing/"&gt;Pushgateway&lt;/a&gt;&lt;br&gt;
&lt;a href="https://kubernetesbyexample.com/pf/"&gt;Port Forward&lt;/a&gt;&lt;br&gt;
&lt;a href="https://kubernetes.io/pt/docs/reference/kubectl/cheatsheet/"&gt;Kubectl cheat sheet&lt;/a&gt;&lt;/p&gt;

</description>
      <category>monitoring</category>
      <category>kubernetes</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
