<?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 Ramiro Berrelleza on Medium]]></title>
        <description><![CDATA[Stories by Ramiro Berrelleza on Medium]]></description>
        <link>https://medium.com/@rberrelleza?source=rss-9971d092a70c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GE44-v68dlzoNtku.</url>
            <title>Stories by Ramiro Berrelleza on Medium</title>
            <link>https://medium.com/@rberrelleza?source=rss-9971d092a70c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 13:15:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rberrelleza/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[We Need a Cloud-Native Development Experience]]></title>
            <link>https://medium.com/okteto/we-need-a-cloud-native-development-experience-322d3834a784?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/322d3834a784</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[development-experience]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Thu, 07 Oct 2021 16:57:21 GMT</pubDate>
            <atom:updated>2021-10-07T17:08:49.755Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N0-TGuW99EKJnwQVHxel7Q.png" /><figcaption>We Need a Cloud-Native Development Experience</figcaption></figure><p>In the beginning, development was straightforward: You wrote code, built a binary, and then ran it in your machine to validate that things worked. You went through this a few times, and once you were happy, you would then SSH into a server, copy your binary, and restart a process. Applications have evolved a lot since those times. Architectural patterns evolved from those single binaries into microservice-based orchestrations that span multiple machines. And our deployment toolkits grew with them: We no longer SSH into servers and copy binaries. We now use sophisticated container orchestrators like Kubernetes and mature deployment practices like GitOps.</p><p>And yet, the development workflow has stayed pretty much the same throughout the years. We clone the code of our project, we start a local copy of the application, we write code, we build a new version of our application, we see the result of it, and we do it all over again (these days, we call this the inner loop). The problem is that instead of compiling a binary and starting a process, we now have to build a bunch of containers and start an entire orchestration of services.</p><p>We go through a lot of trouble to make our machines look like a one-node version of our production clusters. And we are not clueless. We know that this will eat all our memory, CPU, and battery. We know this introduces configuration drift. We know this creates manifest duplication (raise your hand if you run Docker Compose for local dev and Kubernetes in production). We know this makes a dev version, a CI version, and a production version of our services. And still, we keep doing it. Why?</p><h3>Development is not production</h3><p>We have to create these mini-clusters because production and development environments have evolved in opposite directions for the last ten years. Think about this for a second. What do you want from a modern production environment:</p><ul><li>You want it to be immutable</li><li>Easy to redeploy</li><li>Scalable</li><li>Resilient</li><li>Automated</li></ul><p>And what does a typical development environment look like:</p><ul><li>It changes with every code change</li><li>Everything runs on a single machine</li><li>It’s installed and operated by hand</li></ul><p>The current generation of developer tools helps us a lot. Products like Minikube, Docker Desktop, or VSCode’s Dev Containers enable us to transform our development machines into one-node clusters. But the experience is still slow and full of friction. And they do little to solve what I believe is the root cause behind this: <strong>Today, production and development environments are opposites</strong>.</p><h3>Production is not development</h3><p>When talking about this problem, the industry’s first reaction was: Oh, this is simple; let’s give every developer their cluster so they can develop in a realistic development environment. Cloud providers like Civo, AWS, Azure, or Google Cloud certainly make it feasible. Except that now, we’ve made the developer experience even harder.</p><p>Developers now need to be experts in the cloud provider, the infrastructure, the orchestrator, and even the software distribution model. The developer can’t simply change a line of code and see the result anymore, like in the rails sdays. No, our developer now has to perform all these tasks before seeing the results of their work:</p><ul><li>Change a line of code</li><li>Run a make command to build all the artifacts</li><li>Push the artifacts to a registry</li><li>Run the correct argo/helm/kubectl/docker incantation to deploy the application</li><li>Wait for the application to be redeployed</li><li>Finally see the result of their changes</li></ul><p>Don’t you miss running rails s?</p><p>While this is a step forward in the development vs. production divide, this is a slow inner loop. And a slow inner loop only has two outcomes: very frustrated developers (who will eventually quit your team), or very motivated developers who end up hacking their applications to run them on a one-node cluster. I’ve been both types of developers. And neither is fun.</p><h3>We need a Cloud-Native development experience</h3><p>I didn’t make up the points above. They result from hundreds of conversations about developer experience with developers, designers, product managers, founders, and even execs at hundreds of companies. Yes, I do have a thing for developer experience. I even quit my job to do this full time 😜.</p><p>And my conclusion is that a modern Cloud-Native development experience needs to follow these three principles:</p><ol><li>It has to be fast: developers should see their changes in seconds.</li><li>It has to be replicable: deploying a new environment should be “free”.</li><li>It has to be realistic: it should use the same configuration and infrastructure as production.</li></ol><p>These are the core principles that guide the Cloud-Native development experience we are building. We needed a new generation of developer tools that match the new generation of applications. We need rails s, but for a cloud-native world. And that&#39;s Okteto.</p><p><strong>If your application is going to run in a multi-node cluster, why are you developing it in a single machine?</strong> <a href="https://okteto.com/">That is precisely the problem we are tackling with Okteto</a>, and it would make my day if you were to try our approach, and <a href="https://twitter.com/oktetohq">let me know what you think about it</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=322d3834a784" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/we-need-a-cloud-native-development-experience-322d3834a784">We Need a Cloud-Native Development Experience</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remote Development Environments with RubyMine, Okteto, and Kubernetes]]></title>
            <link>https://medium.com/okteto/remote-development-environments-with-rubymine-okteto-and-kubernetes-e6913e1f54fa?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6913e1f54fa</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rubymine]]></category>
            <category><![CDATA[development-environment]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Fri, 13 Aug 2021 00:27:16 GMT</pubDate>
            <atom:updated>2021-08-13T00:27:16.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-rCXMNpAu2yyIVqJmkhWw.png" /><figcaption>Remote Development Environments with RubyMine, Okteto, and Kubernetes</figcaption></figure><p>In the past, we’ve talked about how to develop remotely with <a href="https://okteto.com/blog/remote-kubernetes-development/">VS Code</a> and <a href="https://okteto.com/blog/remote-development-environments-with-pycharm/">PyCharm</a>. Today, I’m going to show you how you can use okteto to define and deploy a fully configured remote development environment for your ruby applications, how to integrate it with <a href="https://www.jetbrains.com/ruby/">RubyMine</a>, and how to use it to build the fastest development experience for Cloud Native applications.</p><p><a href="https://okteto.com/">The Okteto Developer platform</a> allows you to spin up an entire development environment in Kubernetes with one click. This can be as simple as a single container or as complex as a microservice-based Cloud Native Application. You deploy your application with one click, select the component you’re going to develop on, and you’re ready to go in seconds.</p><h3>Install Okteto</h3><p>The <a href="https://okteto.com/docs/getting-started/installation/">Okteto CLI</a> is an open-source single-binary application that allows you to deploy development environments (among other things) in any Kubernetes cluster. It works with Linux, macOS, and Windows. We’ll be using it to create and launch our development environment. Follow the steps below to install it:</p><p><strong>MacOS / Linux</strong></p><pre>$ curl https://get.okteto.com -sSfL | sh</pre><p><strong>Windows</strong></p><pre>Download https://downloads.okteto.com/cli/okteto.exe and add it to your `$PATH`.</pre><h3>Log in to Okteto Cloud</h3><p>Okteto is compatible with any Kubernetes cluster, local or remote. To keep this example simple, we’ll be using <a href="https://okteto.com/">Okteto Cloud</a> to deploy the development environment, but the same instructions apply if you’re using your own <a href="https://okteto.com/enterprise/">Okteto Enterprise</a> instance.</p><p>Run okteto loginin your local console to connect your local machine with your Okteto Cloud account and download your credentials. If you don&#39;t have an account already, you&#39;ll be prompted to create a free account.</p><pre>$ okteto login</pre><pre>Authentication will continue in your default browser<br>You can also open a browser and navigate to the following address:<br>...<br> ✓  Logged in as rberrelleza<br> ✓  Updated context &#39;cloud_okteto_com&#39; in &#39;/Users/ramiro/.kube/config&#39;<br>    Run &#39;okteto namespace&#39; every time you need to activate your Okteto context again</pre><h3>Create a new Ruby project</h3><p>Start by opening RubyMine and creating a new project for your application and development environment. Pick the “Empty Project” template and call it books.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*N1dVKOIwva5rVNDLZPiDfw.png" /><figcaption>Create a new project in RubyMine</figcaption></figure><h3>Define the application manifests</h3><p>Today, we’re building a service to store and retrieve information about books. To keep it simple, it will only have two services: the ruby API, and a database to store the books. When building a new application, I like to begin by defining a ‘skeleton’ of the app. This allows me to deploy a minimalistic version of my application into my development environment, and then iterate directly there.</p><p>Our rest API will be using sinatra(a lightweight DSL for quickly creating web apps) and mysql to handle the data. So we&#39;ll start by creating a Gemfilewith our dependencies. I&#39;m also going to add ruby-debug-ide, so we can debug our application remotely (more on that later).</p><pre># Gemfile<br><br>source &#39;https://rubygems.org&#39;<br><br>gem &#39;sinatra&#39;, require: &#39;sinatra/base&#39;<br>gem &#39;sinatra-contrib&#39;<br>gem &#39;activerecord&#39;<br>gem &#39;mysql2&#39;<br>gem &#39;sinatra-activerecord&#39;<br>gem &#39;rake&#39;<br>gem &#39;puma&#39;<br><br>group :development do<br>  gem &#39;ruby-debug-ide&#39;<br>end</pre><p>Next, let’s create the initial version of our service. Create a app.rbfile with the following content:</p><pre># app.rb<br>require &#39;sinatra&#39;<br>require &#39;sinatra/json&#39;<br><br>class BooksApp &lt; Sinatra::Base<br>  mime_type &#39;application/json&#39;<br><br>  configure do<br>    set :port, 8080<br>    set :bind, &#39;0.0.0.0&#39;<br>  end<br><br>  before do<br>    content_type :json<br>  end<br><br>  get &#39;/&#39; do<br>    p &#39;{&quot;hello&quot;: &quot;world&quot;}&#39;<br>  end<br><br>  run! if $0 == app_file<br>end</pre><p>Now that we have the initial code, let’s define the Dockerfileof the ruby API.</p><pre># Dockerfile<br>FROM ruby:2.7.1<br><br>WORKDIR /usr/src/app<br>COPY Gemfile /usr/src/app<br>RUN bundle install<br>COPY . /usr/src/app<br>EXPOSE 8080<br>CMD [&quot;ruby&quot;, &quot;app.rb&quot;]</pre><p>In this post, we’re going to be using docker-compose, since that&#39;s a format that&#39;s pretty well known, and <a href="https://www.docker.com/blog/from-compose-to-kubernetes-with-okteto/">works great with Okteto Cloud</a>. That being said, the approach described in this post will work with any other deployment tool/format, such as helm charts, or Kubernetes manifests.</p><p>Create a file named docker-compose.yamlat the root of your repository, paste the content below, and save it.</p><pre># docker-compose.yaml<br><br>version: &quot;3&quot;<br>services:<br>  books:<br>    image: okteto.dev/books<br>    build: .<br>    ports:<br>      - 8080:8080<br>    environment:<br>      MYSQL_DATABASE: books<br>      MYSQL_USER: okteto<br>      MYSQL_PASSWORD: passw0rd<br>    depends_on:<br>    - db<br><br>  db:<br>    image: mysql:8<br>    command: --default-authentication-plugin=mysql_native_password<br>    environment:<br>      MYSQL_DATABASE: books<br>      MYSQL_USER: okteto<br>      MYSQL_PASSWORD: passw0rd<br>      MYSQL_ROOT_PASSWORD: r00t<br>    volumes:<br>      - books-data:/var/lib/mysql<br><br>volumes:<br>  books-data:<br>    driver_opts:<br>      size: 1Gi</pre><p>Finally, let’s build and deploy our development environment using the oktetoCLI. Open a terminal in RubyMine, and run the command below:</p><pre>$ okteto stack deploy --build</pre><p>This command will build the image using Okteto’s remote build service, push it to Okteto’s registry, and then deploy the application we just created. Once the application has been deployed, log in to your Okteto Cloud to see the status and to access the endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMv07ESTuAhVjPkJRP7leA.png" /><figcaption>Your development environment running in Okteto Cloud</figcaption></figure><h3>Define your development-time configuration</h3><p>Now that we have a skeleton of our application, it’s time to write some code. But instead of going old school and developing locally and then testing the changes remotely, we’re going to develop our application directly in our remote development container.</p><p>Okteto uses <a href="https://okteto.com/docs/reference/development-environment/">a remote development container</a> to help you build your applications directly in the cloud. Instead of having to write code, then build a container, and then deploy a new version of your application to see your changes, you simply write code and see the results of it reflected instantly in your remote development environment.</p><p>At a high level, a remote development container is a Docker container that contains everything you need to build and develop your application, such as:</p><ul><li>One or more language runtimes (e.g., ruby, python, node)</li><li>SDKs for your language runtime (e.g., JDK, python-dev)</li><li>Binary dependencies (e.g., OpenSSL, git)</li><li>Tools to manage and install dependencies (e.g., bundler, rvm, bundler, yarn)</li><li>Tools to run your tests and analyze your code (e.g., rspec, cucumber)</li></ul><p>Okteto looks for a particular file called okteto.ymlto understand how to create your development container.</p><p>Create a file named okteto.ymlin the booksproject and copy the following content:</p><pre>name: books<br>command: bash<br>volumes:<br>- /usr/local/bundle/cache<br>sync:<br>- .:/usr/src/app<br>remote: 22000<br>forward:<br>- 8080:8080<br>- 1234:1234<br>- 3306:db:3306</pre><p>This file is telling oktetothe following about our development container:</p><ul><li>That it’s for the booksservice.</li><li>To run bash, so we can get a remote terminal.</li><li>To persist /usr/local/bundle/cache, so we can cache our dependencies.</li><li>To <a href="https://okteto.com/docs/reference/file-synchronization/">synchronize the contents</a> of our local folder with /usr/src/appin the remote container.</li><li>To start a remote SSH server on port 22000, so RubyMine can SSH into the remote container.</li><li>To forward port 8080 to the remote environment, in case we want to access our API over localhost:8080.</li><li>To forward port 1234 to the remote environment, so we can start a remote debugging session with RubyMine.</li><li>To forward port 3306 of the dbservice to the remote environment, in case we want to use a local MySQL client.</li></ul><blockquote>Take a look at <a href="https://okteto.com/docs/reference/manifest/">the manifest reference</a> to learn the different configuration settings available.</blockquote><h3>Development time</h3><p>Let’s launch our development container. First, open a local terminal directly in RubyMine. Then, run the okteto upcommand on it to <strong>enable developer mode</strong> in the ruby service. When you enable developer mode, okteto will relaunch your service, applying all the configurations defined in your okteto.ymlmanifest on top of your existing configurations. All the other parts of your application (e.g. the database service, endpoints, etc...) will remain as is.</p><p>Since this is the first time you launch your development environment, the okteto CLI will ask you to create the .stignorefile. Okteto uses this file to know what files to synchronize and which ones to skip. Type yand press enter to continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EtVVEmPHH1AVZuVaEQhrVA.png" /><figcaption>Your development environment is active!</figcaption></figure><blockquote>As long as okteto upis running, Okteto will keep your remote terminal active, your code synchronized, and a SSH session connected.</blockquote><h3>Use your remote development container as an interpreter</h3><p>By default, RubyMine will use your local ruby interpreter for your project. Instead of that, we will configure it to use our remote development container as the target directly. This way, we can guarantee that we always have the correct setup, independent of what happens in our local machine. To do this, we are going to take advantage of RubyMine’s <a href="https://www.jetbrains.com/help/ruby/running-ssh-terminal.html#ssh_remote_interpreter">remote interpreters</a> and Okteto’s <a href="https://okteto.com/docs/reference/manifest/#remote-integer-optional">remote SSH server</a>.</p><p>To add a remote interpreter:</p><ol><li>Open the Settings/Preferencesdialog and go to the Language &amp; Frameworks&gt; Ruby SDK and Gemspage.</li><li>Click the Addicon and select New remote…in the drop-down.</li><li>In the invoked dialog, select SSHfrom the options and click on the Add Interpreter...option in the menu.</li><li>Fill in the following values in the SSH Configurationsdialog, and press the OK button.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*glZw7ish9S6yf0zLqV9JpQ.png" /><figcaption>Add okteto&#39;s SSH configuration</figcaption></figure><blockquote><em>When you run </em><em>okteto upthe first time, Okteto will create an SSH key pair for you and save it at </em><em>$HOME/.okteto/id_rsa_oktetoand </em><em>$HOME/.okteto/id_rsa_okteto.pub. Okteto will automatically configure the SSH server in your development environment to use these keys for authentication.</em></blockquote><p>5. Fill in the following values in the Configure Remote Ruby Interpreterdialog, and press the OK button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*xoM0eVDKb0eskPN4tB4u3g.png" /><figcaption>Finish the interpreter configuration</figcaption></figure><p>6. Select the interpreter we just configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*m_OWwGoU7XfvYtwFJDDzPQ.png" /><figcaption>Add the interpreter</figcaption></figure><p>7. Specify mappings between files of a local and remote project. To do this, click the Edit Path Mappingsbutton on the top. In the Edit Project Path Mappingsdialog, specify the local and remote project root paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*J0YqUt_ErvYZt4ZbQhvgRQ.png" /><figcaption>Don&#39;t forget to set the mappings</figcaption></figure><p>8. Press the OK button to finish the interpreter configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*QDWIExIs4GVmGDwoztfybw.png" /><figcaption>Add okteto&#39;s to your SSH configurations</figcaption></figure><p>From now on, your project will directly use the interpreter in your remote development environment instead of the local one. To try it out, simply right click in app.rband select Run App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n8uSU-2wD7CCcsWzuvIh9Q.png" /><figcaption>Your application running remotely</figcaption></figure><h3>Develop your application in your remote development environment</h3><p>Now that we have our development environment up and running, it’s time to build our API. To keep things simple, we’ll be using ActiveRecord to handle our data layer.</p><p>First, we’ll create config/database.ymlfile to load our MySQL credentials:</p><pre># config/database.yml<br>development:<br>  adapter: mysql2<br>  encoding: utf8<br>  pool: 5<br>  username:  &lt;%= ENV[&#39;MYSQL_USER&#39;] %&gt;<br>  password: &lt;%= ENV[&#39;MYSQL_PASSWORD&#39;] %&gt;<br>  database: &lt;%= ENV[&#39;MYSQL_DATABASE&#39;] %&gt;<br>  host: db</pre><blockquote>You’ll notice that we’re using environment variables to get our DB connection information. Where are they coming from? Well, one of the benefits of using okteto upwhen developing is that your development container automatically inherits all the configuration settings of your services. Every environment variable we defined on our docker-compose.yamlearly on is available here. Just like in production!</blockquote><p>Open app.rb, require activerecord, and establish the connection to our database:</p><pre># app.rb<br>require &#39;sinatra&#39;<br>require &#39;sinatra/json&#39;<br>require &quot;sinatra/activerecord&quot;<br>class BooksApp &lt; Sinatra::Base<br>  mime_type &#39;application/json&#39;</pre><pre>  register Sinatra::ActiveRecordExtension<br>  set :database_file, &#39;config/database.yml&#39;</pre><pre>  configure do<br>    set :port, 8080<br>    set :bind, &#39;0.0.0.0&#39;<br>  end</pre><pre>  before do<br>    content_type :json<br>  end</pre><pre>  get &#39;/&#39; do<br>    p &#39;{&quot;hello&quot;: &quot;world&quot;}&#39;<br>  end</pre><pre>  run! if $0 == app_file<br>end</pre><p>Now create a Rakefilefile and require the rake tasks as well as your app:</p><pre># Rakefile<br>require &quot;sinatra/activerecord/rake&quot;</pre><pre>namespace :db do<br>  task :load_config do<br>    require &quot;./app&quot;<br>  end<br>end</pre><p>With this, we can create the first version of our database schema. Using the terminal where we ran okteto upearlier, run the command below:</p><pre>root@books-5cb9d464f8-qlhz6:/usr/src/app# bundle exec rake db:create_migration NAME=create_books</pre><p>This will create a migration file in your migrations directory (db/migrate), ready for editing. Notice how, even though we created the command on our remote development container, Okteto automatically synchronized the files to your local folder. Cool no?</p><p>Open the migrate script that was automatically created, and update it as shown below. This will create a table called books, with two fields: authorand title.</p><pre>class CreateBooks &lt; ActiveRecord::Migration[6.1]<br>  def change<br>    create_table :books do |t|<br>      t.string :title<br>      t.string :author<br>    end<br>  end<br>end</pre><p>Now run the command below to migrate the database on your remote terminal:</p><pre>root@books-5cb9d464f8-qlhz6:/usr/src/app# bundle exec rake db:migrate</pre><p>With our database and migration scripts configured, let’s update app.rbto read and write from the database.</p><p>First, we’re going to add a hot reloader. This will help us go faster: instead of having to restart the process manually everytime we change it, sinatra will detect any code changes and do it for us.</p><pre># app.rb<br>require &#39;sinatra&#39;<br>require &#39;sinatra/json&#39;<br>require &quot;sinatra/activerecord&quot;<br>require &#39;sinatra/reloader&#39;</pre><pre>class BooksApp &lt; Sinatra::Base<br>  mime_type &#39;application/json&#39;</pre><pre>  register Sinatra::ActiveRecordExtension<br>  set :database_file, &#39;config/database.yml&#39;</pre><pre>  configure do<br>    set :port, 8080<br>    set :bind, &#39;0.0.0.0&#39;<br>  end</pre><pre>  configure :development do<br>    register Sinatra::Reloader<br>  end</pre><pre>  before do<br>    content_type :json<br>  end</pre><pre>  get &#39;/&#39; do<br>    @books = Book.all<br>    @books.to_json<br>  end</pre><pre>  run! if $0 == app_file<br>end</pre><p>After adding the hot reloader, start the service by right clicking on app.rband selecting the Run &quot;app&quot;option. Thanks to our hot reloader, this is the last time we need do to this. From now on, all we need to do is write code and validate our changes 😎.</p><p>Go ahead and add the function to return all the books from the database to app.rb:</p><pre># app.rb<br>require &#39;sinatra&#39;<br>require &quot;sinatra/activerecord&quot;<br>require &#39;sinatra/reloader&#39;<br>require &#39;sinatra/json&#39;</pre><pre>class Book &lt; ActiveRecord::Base<br>end</pre><pre>class BooksApp &lt; Sinatra::Base<br>  mime_type &#39;application/json&#39;</pre><pre>  register Sinatra::ActiveRecordExtension<br>  set :database_file, &#39;config/database.yml&#39;</pre><pre>  configure do<br>    set :port, 8080<br>    set :bind, &#39;0.0.0.0&#39;<br>  end</pre><pre>  configure :development do<br>    register Sinatra::Reloader<br>  end</pre><pre>  before do<br>    content_type :json<br>  end</pre><pre>  get &#39;/&#39; do<br>    @books = Book.all<br>    @books.to_json<br>  end</pre><pre>  run! if $0 == app_file<br>end</pre><p>Save the file, and validate that our changes are working by calling the new API (remember to change the URL for your own) from your local terminal:</p><pre>$ curl <a href="https://books-rberrelleza.staging.okteto.net/">https://books-rberrelleza.staging.okteto.net/</a></pre><pre>[]</pre><p>We got an empty list because our DB is empty. But now we know that everything works end to end!</p><p>Let’s take a second to notice all the things that are happening behind the scenes here:</p><ol><li>We updated a file in our local IDE, and it was automatically synchronized to our remote enviornment.</li><li>We called the new API using an https endpoint (just like our end users would!).</li><li>The API is already querying our DB (that’s why we got an empty response).</li><li>I didn’t have to rebuild, redeploy, or even reload my process to see my changes. It all happened automatically!</li></ol><p>This is the magic of developing with Okteto: develop in a realistic development environment, with high velocity, and high confidence! 🚀</p><p>Let’s repeat the process and add a function to add a book to the database:</p><pre># app.rb<br>require &#39;sinatra&#39;<br>require &quot;sinatra/activerecord&quot;<br>require &#39;sinatra/reloader&#39;<br>require &#39;sinatra/json&#39;</pre><pre>class Book &lt; ActiveRecord::Base<br>end</pre><pre>class BooksApp &lt; Sinatra::Base<br>  mime_type &#39;application/json&#39;</pre><pre>  register Sinatra::ActiveRecordExtension<br>  set :database_file, &#39;config/database.yml&#39;</pre><pre>  configure do<br>    set :port, 8080<br>    set :bind, &#39;0.0.0.0&#39;<br>  end</pre><pre>  configure :development do<br>    register Sinatra::Reloader<br>  end</pre><pre>  before do<br>    content_type :json<br>  end</pre><pre>  get &#39;/&#39; do<br>    @books = Book.all<br>    @books.to_json<br>  end</pre><pre>  post &#39;/&#39; do<br>    new_book = MultiJson.load(request.body.read)<br>    @book = Book.new( new_book )<br>    if @book.save<br>      json @book<br>    else<br>      status 500<br>    end<br>  end</pre><pre>  run! if $0 == app_file<br>end</pre><p>Save the file, and add a new book by executing the code below from a local terminal:</p><pre>$ curl -XPOST https://books-rberrelleza.staging.okteto.net/ --data &#39;{&quot;title&quot;: &quot;telegraph avenue&quot;, &quot;author&quot;: &quot;michael chabon&quot;}&#39;</pre><pre>[{&quot;id&quot;:1,&quot;title&quot;:&quot;telegraph avenue&quot;,&quot;author&quot;:&quot;michael chabon&quot;}]</pre><p>And there you have it! We just built a ruby service that reads and writes from a MySQL database, directly in our remote development environment.</p><h3>Debug your application in your remote development environment</h3><p>Debugging your application remotely follows a very similar approach. First, add a debugging breakpoint in your code (e.g. in the response of one of the GET functions). Then, right click on app.rband the select Debug App. RubyMine will automatically install any required dependencies, and launch the debugger and connect to the remote process.</p><p>Go ahead and call your API using curl, or by directly navigating to the endpoint, and see how RubyMine will automatically stop right in your breakpoint!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*NKEfNqjkui39kapBhoMSUA.png" /><figcaption>Debug directly in Kubernetes with okteto</figcaption></figure><blockquote>If you’re having dependency issues, you can also follow the instructions for remote debugging described <a href="https://okteto.com/blog/how-to-develop-ruby-apps-in-kubernetes/">in this post</a>.</blockquote><h3>Conclusions</h3><p>In this post, we learned about the concept of remote development environments, why they are essential, and how you can use Okteto and RubyMine to build a Cloud Native application faster than ever.</p><p>But this post only covers the surface. Using remote development environments gives you a lot of extra benefits such as:</p><ul><li>Eliminates the need for a local configuration.</li><li>Makes it simple to share the configuration with the rest of your team.</li><li>You don’t need to run docker or a database locally.</li><li>You don’t depend on your workstation’s state.</li><li>You can easily share your development environment with your team.</li><li>It gives you the fastest feedback loop.</li><li>You use your favorite IDEs, debuggers, etc.</li><li>You can take advantage of incremental builds and hot reloaders.</li><li>You are developing in an environment as similar as possible to production.</li><li>You don’t depend on CI/CD for validating all your changes.</li></ul><p>If this problem sounds familiar to you, you should check out what we have built at Okteto. Please take a look at our <a href="https://okteto.com/docs/getting-started/">getting started guide</a> and start developing at the speed of the cloud.</p><p>Our mission at Okteto is to simplify the development of Cloud Native applications. Does this resonate with you? Do you have ideas, comments, or feedback? Join us at the <a href="https://kubernetes.slack.com/messages/CM1QMQGS0/">#okteto</a> channel in the <a href="https://slack.k8s.io/">Kubernetes community Slack</a> and share your thoughts with the community!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6913e1f54fa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/remote-development-environments-with-rubymine-okteto-and-kubernetes-e6913e1f54fa">Remote Development Environments with RubyMine, Okteto, and Kubernetes</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Surprising Results in the 2020 Python Developers Survey]]></title>
            <link>https://medium.com/okteto/surprising-results-in-the-2020-python-developers-survey-428ae4beb72e?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/428ae4beb72e</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Fri, 26 Feb 2021 23:06:17 GMT</pubDate>
            <atom:updated>2021-02-26T23:06:17.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gIaRD6W6ojPJo12c.png" /><figcaption>Surprising Results in the 2020 Python Developers Survey</figcaption></figure><p>Every year, JetBrains and the Python Software Foundation conduct an online survey better to understand the state of Python’s ecosystem.</p><p>In October 2020, more than 28,000 Python developers and enthusiasts from almost 200 countries/regions took the survey, and the results went out earlier this week.</p><p>While I no longer code in Python (Okteto is mostly a golang + react shop), Python was my primary language for many years (Hipchat and Elasticbox were both python-apps), so I like to stay in touch with the community. This morning I went <a href="https://www.jetbrains.com/lp/python-developers-survey-2020/">through the results</a>, and they are quite surprising.</p><h3>Surprise #1:</h3><p><strong>40% of the developers answered that they develop with containers.</strong></p><p>Hipchat was a python application of considerable size), and back then, dealing with virtualenvs and OS-level dependencies was painful for everyone in our dev team.</p><p>It’s great to see that a good chunk of the Python community embraces containers as part of their development workflow and not just for prod. Can we move to Kubernetes now?</p><h3>Surprise #2:</h3><p><strong>68% of the developers use Linux as their primary OS, followed by Windows and then MacOS</strong></p><p>I know I’m super biased by Apple’s prevalence in the Bay Area, but I was still expecting MacOS to do better here. But it is a happy surprise to see Linux take the number one position here.</p><p>I wonder if this has to do with the fact that most applications do run in Linux, and with virtualenvs having deep OS-dependencies, it’s just easier to work in Linux.</p><h3>Surprise #3:</h3><p><strong>Flask and Django are the top web frameworks, but FastAPI is growing fast</strong></p><p>Flask and Django have been the “standard” web frameworks for a very long time now. It is refreshing to see “new blood” starting to rank in this category. The first time I heard about FastAPI was when Abdulazeez proposed we write a series on <a href="https://okteto.com/blog/tags/fastapi/">developing FastAPI-based applications with Okteto</a>. And look at where FastAPI is now!</p><h3>Suprise #4</h3><p><strong>Most Python developers have less than one year of programming experience</strong></p><p>Many people see Python as “old-fashioned” or even a “dead” language. This number and the other demographics-related results in the survey prove that Python is a thriving community and keeps renewing itself.</p><p>There’s also a more profound connotation. This is strong evidence that we have more and more people joining our profession and the python community. I’m all for software being an inclusive profession instead of something just for the few, so this makes me very happy. Artur, from CareerKarma, also <a href="https://okteto.com/blog/stay-relevant-in-the-future-of-work/">touches on that topic here</a>.</p><h3>Suprise #5</h3><p><strong>Most Python developers live outside of the United States.</strong></p><p>The internet is giving people everywhere access to technology and well-paying jobs. You don’t need to move to Silicon Valley anymore to have access to great jobs and build a great career as a developer. It’s not perfect, but we are moving in the right direction.</p><h3>Conclusion</h3><p>Python is alive and well. I love being surprised by surveys like this. It’s a great reminder that good technology can, in fact, last for a very long time and that technology has become a truly global industry. For another take on the survey, I recommend you check <a href="https://www.reddit.com/r/Python/comments/lsaywo/python_developer_survey_reaction_6_insights_to/">MrDon’s reaction</a> to the survey (tell him I said 👋🏼).</p><p><a href="https://okteto.com/blog/python-developers-survey-2020/blog/tags/python/">Okteto ❤️ Python</a>. If you’re building microservices with Python, <a href="https://okteto.com/blog/python-developers-survey-2020/docs/samples/python/index.html">give Okteto a try</a>. And remember, say yes to containers in dev, and no to virtualenvs 😎.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=428ae4beb72e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/surprising-results-in-the-2020-python-developers-survey-428ae4beb72e">Surprising Results in the 2020 Python Developers Survey</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chaos Engineering with Litmus and Okteto Cloud]]></title>
            <link>https://medium.com/okteto/chaos-engineering-with-litmus-and-okteto-cloud-2232ccfa6672?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2232ccfa6672</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[chaos-engineering]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Mon, 24 Aug 2020 17:47:38 GMT</pubDate>
            <atom:updated>2020-08-24T17:47:38.464Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W4fQURM959CavmFk.png" /><figcaption>Chaos Engineering with Litmus and Okteto Cloud</figcaption></figure><p>Cloud Native applications are, by definition, highly distributed, elastic, resistant to failure and loosely coupled. That’s easy to say, and even diagram. But how do we validate that our applications will perform as expected under different failure conditions?</p><p>Enter Chaos engineering. Chaos engineering is the discipline of experimenting on a software system in production in order to build confidence in the system’s capability to withstand turbulent and unexpected conditions. Chaos Engineering is a great tool to help us find weaknesses and misconfiguration in our services. It is particularly important for Cloud Native applications, which, due to their distributed and elastic nature, need to be resilient by default.</p><p><a href="https://litmuschaos.io/">Litmus</a> is a CNCF sandbox project for practicing Chaos Engineering in Cloud Native environments. Litmus provides a chaos-operator, a large set of chaos experiments in its hub, detailed documentation, quick Demo, and a friendly community. In this blog we’ll show you how you can use Litmus and Okteto together to start Chaos testing your applications in a few seconds.</p><h3>Chaos Testing with Litmus</h3><p>When chaos testing an application with LitmusChaos, there are four components that you’ll need to keep in mind.</p><h4>Chaos Operator</h4><p>This is <a href="https://github.com/litmuschaos/litmus">the core part</a> of LitmusChaos. The operator is in charge of executing the experiments, and reporting the results once the experiment is finished.</p><p>You can install it <a href="https://docs.litmuschaos.io/docs/getstarted/#install-litmus">directly from the command line</a>, the <a href="https://hub.helm.sh/charts/litmuschaos/litmus">official helm chart</a>, or <a href="https://cloud.okteto.com/#/spaces/@personal?deploy=litmuschaos">from the Okteto Cloud catalog</a>.</p><h4>Chaos Experiment</h4><p>This is the chaos action that will performed on your application. This goes from Kubernetes specific like deleting a pod, or hogging the network, to application specific actions like randomly deleting an OpenEBS drive.</p><p>The LitmusChaos community maintains <a href="https://hub.litmuschaos.io/">an online hub of chaos experiments</a>.</p><h4>Chaos Engine</h4><p>The Chaos Engine is the link between the chaos experiment and the application under test. This is where you specify any parameters of your experiment such as its duration, enable/disable policies (e.g enable/disable monitoring) as well as information on how to find the targets of the experiment (typically, this is the application under test).</p><h4>Application Under Test</h4><p>This is the application that will be the “target” of the chaos experiment. Currently, LitmusChaos supports Deployments, StatefulSets and DaemonSets. Under the default configuration, you need to add the litmuschaos.io/chaos: &quot;true&quot; tag to the resource for the Chaos Operator to be able to find them, and to prevent other applications from being affected.</p><h3>Prerequistes</h3><p>To chaos-test your application you’ll need to install:</p><ol><li>The <a href="https://okteto.com/docs/getting-started/installation">okteto CLI</a>.</li><li>A free <a href="https://cloud.okteto.com/">Okteto Cloud</a> account.</li><li>kubectl configured <a href="https://okteto.com/docs/cloud/credentials">to talk to Okteto Cloud</a>.</li><li>Your favorite IDE or text editor.</li></ol><h3>Deploy your Chaos-ready Development Environment</h3><p>You can always manually install every component by hand. But instead, I’m taking advantage of Okteto’s <a href="https://okteto.com/blog/cloud-based-development-environments/">pre-configured development environments</a>. Just click on the <strong>Develop on Okteto</strong> button below and deploy your <em>chaos-ready</em> development environment:</p><p>This will automatically deploy the following resources on your Okteto Cloud account:</p><ul><li>The Litmus Chaos operator, from the Okteto catalog</li><li>The pod-delete <a href="https://raw.githubusercontent.com/okteto/litmus-on-okteto/master/chaos/experiment.yaml">chaos experiment</a></li><li>The <a href="https://raw.githubusercontent.com/okteto/litmus-on-okteto/master/application/k8s.yaml">application under test</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CtCzHVQR7ApbgjJI.png" /></figure><h3>Chaos Test the Application</h3><p>Now that we have our development environment, let&#39;s chaos test the application. For this example, we are using the traditional Hello World application, deployed with two replicas. Click on the link and call it a few times to verify that it works fine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*73y-rTJqz3ycGzbv.png" /></figure><p>With the application running, we are ready to start the chaos experiment. In Litmus-speak, this means creating the ChaosEngine resource. Create a file engine.yaml, open it in your favorite IDE, and paste the content below:</p><pre>apiVersion: litmuschaos.io/v1alpha1<br>kind: ChaosEngine<br>metadata:<br>  name: pod-killer-chaos<br>spec:<br>  annotationCheck: &#39;true&#39;<br>  engineState: &#39;active&#39;<br>  appinfo:<br>    applabel: &#39;app=hello-world&#39;<br>    appkind: &#39;deployment&#39;<br>  chaosServiceAccount: default<br>  monitoring: false<br>  jobCleanUpPolicy: &#39;delete&#39;<br>  experiments:<br>    - name: pod-delete<br>      spec:<br>        components:<br>          env:<br>            - name: KILL_COUNT<br>              value: &#39;1&#39;<br>            - name: TOTAL_CHAOS_DURATION<br>              value: &#39;60s&#39;<br>            - name: CHAOS_INTERVAL</pre><p>The ChaosEngine resource has three main sections:</p><ul><li>appinfo: This tells the Litmus operator which application to target. You have to specify a label selector and the type of resource.</li><li>experiments: A list of experiments to run. In this case, we are running the Pod Delete experiment.</li><li>experiments.spec.components: The experiment-specific value overrides. In this case, we are telling the experiment to kill 1 pod over 60 seconds. The available values come from the ChaosExperiment resource.</li></ul><p>Start the chaos experiment by creating the ChaosEngine resource with kubectl:</p><pre>$ kubectl apply -f engine.yaml</pre><pre>chaosengine.litmuschaos.io/pod-killer-chaos created</pre><h3>Witness the Chaos</h3><p>The experiment will kill one of our application’s pods. If you run the command below once the experiment has started, you’ll see how a random pod is killed and then automatically recreated:</p><pre>$ kubectl get pod -l=app=hello-world</pre><pre>NAME READY STATUS RESTARTS AGE<br>hello-world-75947547d4–2fcbc 1/1 Running 0 57m<br>hello-world-75947547d4-c6wsv 0/1 ContainerCreating 0 10s</pre><p>While the experiment is running, keep refreshing the browser. Notice how the calls will display different pod names, but they were never interrupted? That’s because our application is resilient to pod destruction 💪🏻!</p><p>When an experiment is created, a ChaosResult resource will created to hold the result of the experiment. The status.verdict key is set to Awaited while the experiment is in progress. Once it finishes, it will change to either Pass or Fail.</p><pre>$ kubectl describe chaosresult pod-killer-chaos-pod-delete</pre><pre>Name: pod-killer-chaos-pod-delete<br>Namespace: rberrelleza<br>Labels: name=pod-killer-chaos-pod-delete<br>Annotations: &lt;none&gt;<br>API Version: litmuschaos.io/v1alpha1<br>Kind: ChaosResult<br>Metadata:<br> Creation Timestamp: 2020–08–05T21:14:05Z<br> Generation: 5<br> Resource Version: 165298631<br> Self Link: /apis/litmuschaos.io/v1alpha1/namespaces/rberrelleza/chaosresults/pod-killer-chaos-pod-delete<br> UID: a7f50d28–1f14–4a03–9013–94e72d69eb72<br>Spec:<br> Engine: pod-killer-chaos<br> Experiment: pod-delete<br>Status:<br> Experimentstatus:<br> Fail Step: N/A<br> Phase: Running<br> Verdict: Awaited<br>Events:<br> Type Reason Age From Message<br> — — — — — — — — — — — — -<br> Normal Summary 45m experiment-l0k004–5x2fj pod-delete experiment has been Passed</pre><h3>Extra Chaos</h3><p>In a future post I’ll show how you can take your chaos testing to the next level and write your own application-specific experiments. Can’t wait? <a href="https://github.com/ksatchit">Karthik</a> from MayaData wrote <a href="https://dev.to/ksatchit/litmus-sdk-devtest-your-chaos-experiments-with-okteto-4dkj">a pretty cool getting started guide</a>. And it happens to use the okteto CLI as part of the dev flow. How cool is that?</p><p>Litmus has <a href="https://hackmd.io/a4Zu_sH4TZGeih-xCimi3Q?view">a monthly community call</a> where the community gets together and talks about their cool use cases and needs. The team was nice enough to invite me to <a href="https://www.youtube.com/watch?v=kPFwrPe84sY&amp;feature=youtu.be">this month’s call</a> to demo the workflow I showed you on this post. It’s a great place to talk and learn from other practitioners.</p><h3>Conclusion</h3><p>In this post, we showed how you can deploy a replicable development environment that includes an application, the LitmusChaos operator, and your chaos experiment, all in one click. Then, we ran a chaos experiment, validating that our application is resilient to a pod failure.</p><p>This is a great example of how you can <a href="https://okteto.com/">use Okteto to accelerate your entire team</a>. One person configures the app with the chaos tools, and everyone else can create their own namespace on demand, deploy a pre-configured, chaos-ready development environment, and start running experiments without having to think twice about installation scripts or infrastructure configuration.</p><p>Let’s keep the conversation going! Join the <a href="https://slack.okteto.com/">Okteto</a> and <a href="https://slack.litmuschaos.io/">Litmus</a> communities to talk more about Cloud Native development and Chaos Engineering.</p><p><em>Thanks to Karthik Satchitanand and Prithvi Raj for reading drafts of this.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2232ccfa6672" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/chaos-engineering-with-litmus-and-okteto-cloud-2232ccfa6672">Chaos Engineering with Litmus and Okteto Cloud</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remote Development Environments with PyCharm, Okteto and Kubernetes]]></title>
            <link>https://medium.com/okteto/remote-development-environments-with-pycharm-okteto-and-kubernetes-bb0a70170cb5?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb0a70170cb5</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Tue, 12 May 2020 18:08:46 GMT</pubDate>
            <atom:updated>2021-04-17T01:30:49.086Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GHI1qrTG1w9Mj-vT.png" /></figure><p>In the past, we’ve talked about <a href="https://okteto.com/blog/remote-kubernetes-development/">how to develop remotely with VS Code</a>. Today, I’m going show you how can you use okteto to define and deploy a fully configured remote development environment for your python application, how to integrate it with <a href="https://www.jetbrains.com/pycharm/">Jetbrains&#39; PyCharm</a> and how to use it to build a Cloud Native application.</p><p><a href="https://okteto.com/">The Okteto Developer platform</a> allows you to spin up an entire development environment in Kubernetes with one click. This can be as simple as a single container or as complex as a microservice-based Cloud Native Application. You deploy your application with one click, select the component you’re going to develop on, and you’re ready to go in seconds.</p><h3>Install Okteto</h3><p>The <a href="https://okteto.com/docs/getting-started/installation">Okteto CLI</a> is an open source single-binary application that allows you to deploy development environments (among other things) in any Kubernetes cluster. It works with Linux, MacOS and Windows. We’ll be using it to create and launch our development environment. Follow the steps below to install it:</p><p>MacOS / Linux</p><pre>$ curl https://get.okteto.com -sSfL | sh</pre><p>Windows</p><pre>Download https://downloads.okteto.com/cli/okteto.exe and add it to your `$PATH`.</pre><h3>Configure your Kubernetes Access</h3><p>Okteto is compatible with any Kubernetes cluster, local or remote. To keep this example simple, we are going to be using <a href="https://okteto.com/">Okteto Cloud</a> to deploy the development environment. If you prefer to use your own Kubernetes cluster, you can skip this step.</p><p>Run okteto login in your local console to create a free Okteto Cloud account, login, and to download your Kubeconfig. We’ll be needing it later in the post.</p><pre>$ okteto login</pre><pre>Authentication will continue in your default browser<br>You can also open a browser and navigate to the following address:<br>…<br> ✓ Logged in as rberrelleza<br> ✓ Updated context ‘cloud_okteto_com’ in ‘/Users/ramiro/.kube/config’<br> Run ‘okteto namespace’ every time you need to activate your Okteto context again</pre><h3>Create a New Python Project</h3><p>Start by opening PyCharm and creating a new project for your application and development environment. Pick the “Pure Python” template and call it guestbook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/0*xTJmZghVlj9uCdKD.png" /></figure><h3>Define your Remote Development Environment</h3><p>At a high level, <a href="https://okteto.com/docs/reference/development-environment">a remote development environment</a> is a Docker container that contains everything you need to build and develop your application, such as:</p><ul><li>One or more language runtimes (e.g python, ruby, node)</li><li>SDKs for your language runtime (e.g JDK, python-dev)</li><li>Binary dependencies (e.g. openssl, git)</li><li>Tools to manage and install dependencies (e.g. pip, bundler, yarn)</li><li>Tools to run your tests and analyze your code (e.g nosetest, pylint)</li></ul><p>Okteto looks for a special file called okteto.yaml to define the development environment for an application.</p><p>Create a file named okteto.yaml in the guestbook project and copy the following content:</p><pre>name: guestbook<br>autocreate: true<br>image: okteto/python:3<br>remote: 2222<br>forward:<br>  - 8080:8080<br>command: [&quot;bash&quot;]</pre><p>This file is telling okteto to perform the following:</p><ul><li>Create a development environment named guestbook .</li><li>Automatically create it if it&#39;s missing.</li><li>Use the Docker image okteto/python:3 .</li><li>Start an SSH server on port 2222.</li><li>Forward port 8080 to the remote environment.</li><li>Run bashwhen the remote dev container starts, so we get a remote terminal.</li></ul><blockquote>Take a look at <a href="https://okteto.com/docs/reference/manifest">the manifest reference</a> to learn the different configuration settings available.</blockquote><h3>Deploy your Remote Development Environment</h3><p>Let’s deploy the development environment. First, open a local terminal directly in Pycharm. Then, run the okteto up command on it.</p><p>Since this is the first time you launch your development environment, you’ll be asked to confirm if you want to create it. Type y and press enter to continue.</p><p>The okteto up command will perform the following tasks automatically:</p><ul><li>Deploy the development environment as described by okteto.yml into Okteto Cloud (or your personal Kubernetes cluster).</li><li>Forward port 8080 to the remote environment.</li><li>Start an SSH server in port 2222.</li><li>Start a <a href="https://okteto.com/docs/reference/file-synchronization/index.html">file synchronization service</a> to keep your changes up-to-date between your local filesystem and your application pods.</li><li>Launch a remote shell in your remote development environment. Now you can build, test, and run your application as if you were in your local machine.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l3-m87nUhz13zj32.png" /></figure><h3>Use your Remote Environment as an Interpreter</h3><p>By default, PyCharm will use your local python interpreter for your project. Instead of that, we’re going to configure it to directly use our remote development environment as the target. This way, we can guarantee that we always have the right setup, independent of what happens in our local machine. To do this, we are going to take advantage of PyCharm’s <a href="https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html">remote interpreters</a> and Okteto’s <a href="https://okteto.com/docs/reference/manifest#remote-integer-optional">remote SSH server</a>.</p><p>To add a remote interpreter, right-click on the status bar in the bottom right of the screen, and click on the Add Interpreter... option in the menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pr909Fq5i-ubj7LA.png" /></figure><p>Then, select the SSH Interpreter option on the left, and Existing server configuration on the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/0*FsAg9M-1TSVPtIE-.png" /></figure><p>Click on the button with the three dots in the right to launch the SSH Configuration dialog, and add a new configuration with the same values as shown below, replacing /Users/ramiro with the path to your $HOME directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*_7rJPrOb11Qi0OCp.png" /></figure><p>Press the Test Connection button to validate that everything is configured correctly.</p><blockquote>When you run okteto up the first time, Okteto will create a SSH key pair for you and save it at $HOME/.okteto/id_rsa_okteto and $HOME/.okteto/id_rsa_okteto.pub. The SSH server launched in your development environment will be automatically configured to use these keys for authentication.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/0*Ab2olfre7R7SWQ4V.png" /></figure><p>Once the SSH configuration is completed, click on the Next button, to get to the final configuration screen (yay!).</p><p>Update the path to the interpreter to match the one in your remote development environment (/usr/local/bin/python), set the folder mapping to /okteto and disable file uploading, since Okteto will automatically take care of this for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/0*FBh4zWBE0fXFSFkv.png" /></figure><p>Click on the Finish button to save your configuration.</p><blockquote>The interpreter configuration is saved in the .idea folder. You can include this configuration in your repository so the rest of your team can benefit from it.</blockquote><p>From now on, your project will directly use the interpreter in your remote development environment, instead of the local one. Why don’t you open PyCharm’s python console and try it out?</p><h3>Develop your Application in your Remote Development Environment</h3><p>Now that we have our development environment up and running, it’s time to build our application. For the purpose of this post, we are going to build a an application that lets users post messages to a public message.</p><p>The application will include:</p><ul><li>A flask web server that handles the display and updates to the guestbook.</li><li>A MongoDB instance to store the messages.</li></ul><h3>Deploy your MongoDB Instance</h3><p>One of the big advantages of using remote development environments is that we don’t have to run anything locally. Since the development environment is running in Kubernetes, it has access to anything available there, such as secrets, other services, databases, etc.</p><p>For MongoDB, you can take advantage of Okteto Cloud’s Application Catalog and deploy it with one click.</p><p>To do this, open your browser, go to <a href="https://cloud.okteto.com/">Okteto Cloud</a>, click on the Deploy button, select MongoDB from the list of applications, and click on the Deploy button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lsRbmZqkeymKDjQq.png" /></figure><p>Wait for a few seconds for your instance to finish deploying. You’ll be able to see the status directly in Okteto Cloud’s dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CRQ1PbUMTeZh2ZC1.png" /></figure><blockquote>If you deployed your development environment in your own cluster, you can deploy it using <a href="https://github.com/helm/charts/tree/master/stable/mongodb-replicaset">the official Helm Chart</a>.</blockquote><h3>Developing Directly on Kubernetes</h3><p>Now that we have our development environment and our MongoDB instance, let’s build our application.</p><p>First, create a python file called app.py in your project. This is the file that will contain our server’s code, so let’s start with the basics. Copy the code below in app.py:</p><pre>from flask import Flask<br>from flask_pymongo import PyMongo<br></pre><pre>app = Flask(__name__)<br>app.config[&quot;MONGO_URI&quot;] = &quot;mongodb://okteto:okteto@mongodb:27017/okteto&quot;<br>mongo = PyMongo(app)<br></pre><pre>if __name__ == &#39;__main__&#39;:<br> app.run(host=’0.0.0.0&#39;, port=8080)</pre><p>The code above will perform the following:</p><ul><li>Import flask and flask_pymongo.</li><li>Configure the mongo connection string and data access object.</li><li>Start the webserver.</li></ul><blockquote>Note that we are using mongodb:27107 as the name and port of the MongoDB instance, instead of the typical localhost. This is because our development environment is running in Kubernetes, just as MongoDB, so we can access it using its DNS name. Just like we would do in production 💫.</blockquote><p>As soon as you save the file, errors will appear on the first two lines. This is because our development environment doesn’t have them installed yet. To install them, go to the console (the one with the okteto &gt; prompt) and pip install the requirements, just like you would do locally:</p><pre>rberrelleza:guestbook okteto&gt; pip install flask flask_pymongo</pre><pre>…<br>Installing collected packages: MarkupSafe, Jinja2, itsdangerous, click, Werkzeug, flask, PyMongo, flask-pymongo<br>Successfully installed Jinja2–2.11.2 MarkupSafe-1.1.1 PyMongo-3.10.1 Werkzeug-1.0.1 click-7.1.2 flask-1.1.2 flask-pymongo-2.3.0 itsdangerous-1.1.0</pre><p>When installing dependencies, is a good practice to add them to your requirements.txt file, so it reflects all your runtime dependencies. Run the pip freeze command in the same console:</p><pre>rberrelleza:guestbook okteto&gt; pip freeze &gt; requirements.txt</pre><p>If you wait a couple of seconds, you’ll see that the requirements.txt file appears in your project automatically. This is the magic of okteto’s file synchronization. Any file change in the remote development environment or locally will be automatically synchronized on the other side.</p><p>Run python app.py in the console to start the server:</p><pre>rberrelleza:guestbook okteto&gt; python app.py</pre><pre>* Serving Flask app “app” (lazy loading)<br>* Environment: production<br> WARNING: This is a development server. Do not use it in a production deployment.<br> Use a production WSGI server instead.<br>* Debug mode: on<br>* Running on <a href="http://0.0.0.0:8080/">http://0.0.0.0:8080/</a> (Press CTRL+C to quit)<br>* Restarting with stat<br>* Debugger is active!<br>* Debugger PIN: 160–502–646</pre><p>Your application is up and running, directly in your remote development environment. To access it, open your browser and go to http://localhost:8080. (this is why we included a forwarding rule for port 8080 in the okteto.yml manifest).</p><p>What’s cool is that your application is also running on debug mode. This means that flask will automatically reload your application every time the code changes. Let’s try that by finishing our application’s code.</p><p>Update app.py as follows:</p><pre>from flask import Flask, jsonify, request<br>from flask_pymongo import PyMongo<br><br>app = Flask(__name__)<br>app.config[&quot;MONGO_URI&quot;] = &quot;mongodb://okteto:okteto@mongodb:27017/okteto&quot;<br>mongo = PyMongo(app)<br><br>@app.route(&quot;/&quot;, methods=[&quot;GET&quot;])<br>def get_messages():<br>  messages = []<br>  for m in mongo.db.messages.find():<br>   messages.append({&quot;message&quot;: m[&quot;message&quot;], &quot;user&quot;: m[&quot;user&quot;]})<br>  return jsonify(messages=messages)<br><br>@app.route(&quot;/&quot;, methods=[&quot;POST&quot;])<br>def post_message():<br>  content = request.json<br>  mongo.db.messages.insert_one({&quot;message&quot;: content[&quot;message&quot;], &quot;user&quot;: content[&quot;user&quot;]})<br>  return &#39;&#39;, 204<br><br>if __name__ == &#39;__main__&#39;:<br>  app.run(host=&#39;0.0.0.0&#39;, port=8080, debug=True)</pre><p>With this change, the application will:</p><ul><li>Accept a POST request on /. It will read the message and user from the request’s content and insert them into the MongoDB database.</li><li>Accept a GET request on /. It will get all the available messages from MongoDB, and return them as a json array.</li></ul><p>As soon as you save the files, okteto will detect the changes and synchronize them to your remote development environment. Then, flask will automatically reload them.</p><p>Try the application by calling the new endpoints. Open a second console in PyCharm, and post a few messages:</p><pre>➜ guestbook $ curl -XPOST -H “content-type: application/json” <a href="http://localhost:8080/">http://localhost:8080</a> -d ‘{“message”: “hello”, “user”:”ramiro”}’</pre><pre>➜ guestbook $ curl -XPOST -H “content-type: application/json” <a href="http://localhost:8080/">http://localhost:8080</a> -d ‘{“message”: “how are you?”, “user”:”cindy”}’</pre><pre>➜ guestbook $ curl -XPOST -H “content-type: application/json” <a href="http://localhost:8080/">http://localhost:8080</a> -d ‘{“message”: “developing directly in my cluster!”, “user”:”ramiro”}’</pre><p>And then get them:</p><pre>➜ guestbook $ curl <a href="http://localhost:8080/">http://localhost:8080</a></pre><pre>{<br> “messages”: [<br> {<br>   “message”: “hello”, <br>   “user”: “ramiro”<br> }, <br> {<br>   “message”: “how are you?”, <br>   “user”: “cindy”<br> }, <br> {<br>   “message”: “developing directly in my cluster!”, <br>   “user”: “ramiro”<br> }<br> ]<br>}</pre><p>At this point, our application is feature complete, and we already tested it end to end in a fully integrated remote development environment. All that’s left is to package it, send a PR, and ship it!</p><h3>Conclusions</h3><p>In this post we learned about the concept of remote development environments, why they are important, and how you can use Okteto and PyCharm to use them to build a Cloud Native application faster than ever.</p><p>But this post only covers the surface. Using remote development environments gives you a lot of extra benefits such as:</p><ul><li>Eliminates the need for a local configuration.</li><li>Makes it simple to share the configuration with the rest of your team.</li><li>You don’t need to run Docker or Kubernetes locally.</li><li>You don’t depend on your workstation’s state.</li><li>You can easily share your development environment with your team.</li><li>It gives you the fastest feedback loop.</li><li>You use your favorite IDEs, debuggers, etc…</li><li>You can take advantage of incremental builds and hot-reloaders.</li><li>You are developing on an environment as similar as possible to production.</li><li>You don’t depend on CI/CD for validating all your changes.</li></ul><p>If this problem sounds familiar to you, you should check out what we have built at Okteto. Take a look at our <a href="https://okteto.com/docs/tutorials/e2e/index.html">getting started guide</a> and start developing at the speed of the cloud.</p><p>Our mission at Okteto is to simplify the development of Cloud Native applications. Does this resonate with you? Do you have ideas, comments, or feedback? Join us at the <a href="https://kubernetes.slack.com/messages/CM1QMQGS0/">#okteto</a> channel in the Kubernetes community Slack and share your thoughts with the community!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb0a70170cb5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/remote-development-environments-with-pycharm-okteto-and-kubernetes-bb0a70170cb5">Remote Development Environments with PyCharm, Okteto and Kubernetes</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build your React + Express App in Okteto Cloud]]></title>
            <link>https://medium.com/okteto/build-your-react-express-app-in-okteto-cloud-a85a612a40f6?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a85a612a40f6</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Thu, 23 Apr 2020 15:01:01 GMT</pubDate>
            <atom:updated>2020-04-23T15:54:17.460Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n_Qu1ynTHdp08fMB.png" /></figure><p>React is a JavaScript library for building user interfaces. It was originally created by Facebook, and over the years it has become one of the most broadly used frontend libraries. React is particularly powerful when building single-page or mobile apps.</p><p>You can build your React frontend locally. The local development experience is one of the best there is. But is very likely that, in production, your React frontend is going to to work along with other services, like a backend, or a database. What are you going to do then? Typically you’d end up mocking the backend, or calling a staging version, rendering your local development environments very complex…</p><p>In this post I’ll show how you can take advantage of the different features of <a href="https://cloud.okteto.com/">Okteto Cloud</a> to make it easier than ever to build a React application. You can still benefit from React’s local development experience, but you’ll also have access to a fully integrated, production-like development environment, backend included. Hello okteto up, goodbye production-only bugs 👋🏼!</p><blockquote>If you feel like skipping all the instructions, the final version of the application we are building on this post <a href="https://github.com/okteto/react-express">is available here</a>.</blockquote><h3>Initial Setup</h3><p>First, install the<a href="https://okteto.com/docs/getting-started/installation"> Okteto CLI.</a> We’ll be using it to create out development environment and to build and deploy our application.</p><h4>MacOS/Linux</h4><pre>$ curl <a href="https://get.okteto.com/">https://get.okteto.com</a> -sSfL | sh</pre><h4>Windows</h4><pre>$ wget <a href="https://downloads.okteto.com/cli/okteto-Windows-x86_64">https://downloads.okteto.com/cli/okteto-Windows-x86_64</a> -OutFile c:\windows\system32\okteto.exe</pre><p>Then, create a folder for our code:</p><pre>$ mkdir my-app</pre><h3>Launch your Development Environment</h3><p>One of the big advantages of using the Okteto CLI is that it gives us the ability to define and launch development environments directly in Okteto Cloud. This way, we can have all our tools and dependencies pre-installed and available for us with one command, instead of having to mess with local configuration and conflicting setups.</p><p>Initialize your development environment by running the okteto init command. Since we are building a React app, we’ll pick the javascript template:</p><pre>$ cd my-app<br>$ okteto init</pre><pre>Recommended image for development with javascript: okteto/node:10<br>Which docker image do you want to use for your development environment? [okteto/node:10]:</pre><pre> ✓ Okteto manifest (okteto.yml) created</pre><p>This command will create two files in your folder, okteto.yml and .stignore. okteto.yml is what tells the Okteto CLI how your development environment looks like. In this case, it’s telling it that you want to use okteto/node:10 as the image, that your workdir is /usr/src/app, and that the starting command will be bash. .stignore tells the Okteto CLI which files not to synchronize to your development environment (more on this later).</p><p>Now that we have our manifest, let’s launch our development environment. First, let’s login to Okteto Cloud by running the okteto login command. The command will open a browser so you can authenticate with github, and it will download your Okteto Cloud credentials and certificates. If this is the first time you use Okteto Cloud, it will also create a free account for you.</p><pre>$ okteto login</pre><pre>Authentication will continue in your default browser<br>You can also open a browser and navigate to the following address:<br>…<br>…<br> ✓ Logged in as rberrelleza<br> ✓ Updated context ‘cloud_okteto_com’ in ‘/Users/ramiro/.kube/config’<br> Run ‘okteto namespace’ every time you need to activate your Okteto context again.</pre><p>Now that we are logged in, run the okteto up command to launch your development environment. Since this is the first time we launch it, we’ll use the --deploy argument.</p><pre>$ okteto up — deploy</pre><pre>✓ Development environment activated<br> ✓ Files synchronized<br> Namespace: rberrelleza<br> Name: my-app</pre><pre>Welcome to your development environment. Happy coding!<br>okteto&gt;</pre><p>With this, your development environment is up and running in Okteto Cloud, and you have a remote terminal to access it from (remember the bash command in okteto.yml?). But that’s not all. okteto up also keeps your local folder and your remote development environment synchronized. Any file you edit, locally or remote, will be instantly synchronized in the other side (unless it’s listed on .stignore).</p><h3>Create the Initial App</h3><p>To create the initial skeleton of the application, we’re going to be using <a href="https://create-react-app.dev/docs/getting-started/">create-react-app</a>. Run the following command on your remote development environment to build yours:</p><pre>okteto&gt; npx create-react-app client</pre><pre>npx: installed 99 in 16.715s</pre><pre>Creating a new React app in /usr/src/app/client.</pre><pre>Installing packages. This might take a couple of minutes.<br>Installing react, react-dom, and react-scripts with cra-template…<br>…<br>…<br>…<br>We suggest that you begin by typing:</pre><pre> cd client<br> yarn start</pre><pre>Happy hacking!</pre><p>After a minute or two, the command will finish installing all the required files and dependencies. If you go ahead and open your local IDE you’ll see that the files are already there, courtesy of okteto‘s file synchronization capabilities.</p><p>Follow the instructions in the UI (with a small addition) and start your React application:</p><pre>$ export PORT=8080<br>$ cd client<br>$ yarn start</pre><p>When you launch your development environment in Okteto Cloud, you automatically get a public HTTPS endpoint for it, valid certificate included. All you need to do is make sure that your process starts in port 8080 (that’s why I sneaked in the export in the commands above). This way you can start accessing your application the same way your users are going to, from the very beginning. Get the URL of the endpoint by going to <a href="https://cloud.okteto.com/">Okteto Cloud</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bFePDVNusvJcQUPe.png" /></figure><p>Click on the URL to see your application live in Okteto Cloud!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FednNz_Tpnambtfs.png" /></figure><h3>Develop your Application</h3><p>Now that we have our initial application running, it’s time to hack on it a little bit. How about we replace the React logo for Okteto’s?</p><p>Load the my-app folder in your favorite IDE, and open client/src/App.js. This is the file that has the main logic of the application. Modify it so that it uses <a href="https://okteto.com/icons/icon-384x384.png">Okteto’s logo</a> instead of React’s:</p><pre>import React from &#39;react&#39;;<br>import &#39;./App.css&#39;;<br></pre><pre>function App() {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;header className=&quot;App-header&quot;&gt;<br>      &lt;img src=&quot;https://okteto.com/icons/icon-384x384.png&quot; className=&quot;App-logo&quot; alt=&quot;logo&quot; /&gt;</pre><pre>      &lt;p&gt;<br>        Edit &lt;code&gt;src/App.js&lt;/code&gt; and save to reload.<br>      &lt;/p&gt;<br>      &lt;a<br>        className=&quot;App-link&quot;<br>        href=&quot;https://reactjs.org&quot;<br>        target=&quot;_blank&quot;<br>        rel=&quot;noopener noreferrer&quot; <br>      &gt;<br>        Learn React<br>      &lt;/a&gt;<br>    &lt;/header&gt;<br>  &lt;/div&gt;<br> );<br>}</pre><pre>export default App;</pre><p>Save the file and go to your browser. Wait for a second, and see how it automatically changes into the Okteto logo. This is the same experience you get when developing locally. But it’s happening directly in your remote development environment 🧙‍♂️!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AoOs9WPpk5cTSLxs.png" /></figure><h3>How did that happen?</h3><p>When you saved the file, it automatically triggered the following events:</p><ol><li>Okteto detected the local change, and synchronized it to your remote development environment.</li><li>The react dev server detected the change, and automatically regenerated the files.</li><li>React use their dev websocket to automatically reload the content on your browser.</li></ol><p>Pretty cool no?</p><h3>How About an API?</h3><p>Now that we have our frontend running, how about giving it an API? For this example, let’s create a simple API that returns the URL of the logo, instead of having it hardcoded in the URL.</p><p>We’ll do our API in NodeJS, to keep things in the Javascript family. Go back to your IDE, create server.js and paste the following code on it:</p><pre>const express = require(&#39;express&#39;);<br>const bodyParser = require(&#39;body-parser&#39;)<br>const app = express();<br>const port = process.env.PORT || 3000;<br>app.use(bodyParser.json());<br>app.use(bodyParser.urlencoded({ extended: true }));</pre><pre>app.get(&#39;/api&#39;, (req, res) =&gt; {<br>  res.json({logo: &#39;https://okteto.com/icons/icon-384x384.png&#39;});<br>});</pre><p>Then, create package.json, and paste the content below.</p><pre>{<br>  &quot;name&quot;: &quot;react-express&quot;,<br>  &quot;main&quot;: &quot;server.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;server&quot;: &quot;nodemon server.js&quot;<br>  },<br>  &quot;devDependencies&quot;: {<br>    &quot;concurrently&quot;: &quot;^5.1.0&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;body-parser&quot;: &quot;^1.19.0&quot;,<br>    &quot;express&quot;: &quot;^4.17.1&quot;,<br>    &quot;nodemon&quot;: &quot;^2.0.3&quot;<br> }<br>}</pre><p>Go back to your remote terminal and stop React’s web server (ctrl+c should do it). Then, go back to the workdir of your remote environment (/usr/src/app) and install the required dependencies by running yarn install:</p><pre>okteto&gt; yarn install</pre><pre>yarn install v1.22.4<br>…<br>…<br>…<br>success Saved lockfile.<br>Done in 54.50s.</pre><p>Start your API by running yarn start:</p><pre>okteto&gt; yarn start</pre><pre>yarn run v1.22.4<br>warning package.json: No license field<br>$ node server.js<br>Listening on port 8080</pre><p>You can validate that your API is doing the right thing by going back to the browser, add /api to the URL and hit enter. This time, you’ll get the output of the API instead of your React app since that’s the process that we are currently running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QAIaE86_yVQMfsaP.png" /></figure><p>To run it all together, we are going to use React’s <a href="https://create-react-app.dev/docs/proxying-api-requests-in-development/">API proxy feature</a>. This allows to both serve our static assets as well as API calls from the same server. To enable it, add the proxy key to client/package.json:</p><pre>…<br>&quot;proxy&quot;: &quot;http://localhost:3000&quot;<br>…</pre><p>We are also going to add the following scripts to package.json to be able to start both the react dev server and server.js at the same time:</p><pre>…<br>&quot;scripts&quot;: {<br> &quot;server&quot;: &quot;nodemon server.js&quot;,<br> &quot;client&quot;: &quot;yarn — cwd client start&quot;,<br> &quot;dev&quot;: &quot;concurrently — kill-others-on-fail \&quot;PORT=3000 yarn server\&quot; \&quot;DANGEROUSLY_DISABLE_HOST_CHECK=true yarn client\&quot;&quot;<br>},<br>…</pre><p>Head back to your remote terminal, stop server.js and run yarn dev to start both servers this time:</p><pre>okteto&gt; yarn dev</pre><pre>yarn run v1.22.4<br>…<br>…</pre><p>Now that be have both our React app and our API running, let’s put them to work together. For this, we are going to use React’s <a href="https://reactjs.org/docs/react-component.html#componentdidmount">componentDidMount()</a> hook to call the API right before the browser displays. To do this, update client/src/App.js as follows:</p><pre>import React, {Component} from &#39;react&#39;;<br>import &#39;./App.css&#39;;</pre><pre>class App extends Component {<br>  state = {logo: &#39;&#39;};<br>  componentDidMount(){<br>    fetch(&#39;/api&#39;)<br>    .then(r =&gt; r.json())<br>    .then(b =&gt; this.setState({logo: b.logo}))</pre><pre>  }</pre><pre> render(){<br>   return(<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;header className=&quot;App-header&quot;&gt;<br>        &lt;img <br>          src={this.state.logo}<br>          className=&quot;App-logo&quot;<br>          alt=&quot;logo&quot; /&gt;<br>        &lt;p&gt;Edit &lt;code&gt;src/App.js&lt;/code&gt; and save to reload.&lt;/p&gt;<br>        &lt;a<br>           className=&quot;App-link&quot;<br>           href=&quot;https://reactjs.org&quot;<br>           target=&quot;_blank&quot;<br>           rel=&quot;noopener noreferrer&quot; &gt;<br>           Learn React<br>         &lt;/a&gt;<br>       &lt;/header&gt;<br>     &lt;/div&gt;);<br>  }<br>}</pre><pre>export default App;</pre><p>Go back to your browser and reload the page, to see everything working together. If you open your developer tools to inspect the requests, you will be able to see the call to our new API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*efRL_M8GlxsgT_o0.png" /></figure><h3>Ship it!</h3><p>Now that our code is ready, it’s time to ship it. For this, we are going to take advantage of two of Okteto Cloud’s features: Okteto Build Service and the Okteto Registry.</p><p>First, let’s make a final change to our application to enable production mode. Open server.js and make the following changes:</p><pre>const express = require(&#39;express&#39;);<br>const bodyParser = require(&#39;body-parser&#39;)<br>const path = require(&#39;path&#39;)<br>const app = express();<br>const port = process.env.PORT || 3000;</pre><pre>app.use(bodyParser.json());<br>app.use(bodyParser.urlencoded({ extended: true }));</pre><pre>app.get(&#39;/api&#39;, (req, res) =&gt; {<br>  res.json({logo: &#39;https://okteto.com/icons/icon-384x384.png&#39;});<br>});</pre><pre>if (process.env.NODE_ENV === &#39;production&#39;) {<br>  // Serve any static files<br>  app.use(express.static(path.join(__dirname, &#39;client/build&#39;)));</pre><pre>  // Handle React routing, return all requests to React app<br>  app.get(&#39;*&#39;, function(req, res) {<br>    res.sendFile(path.join(__dirname, &#39;client/build&#39;, &#39;index.html&#39;));<br>  });<br>}</pre><pre>app.listen(port, &quot;0.0.0.0&quot;, () =&gt; console.log(`Listening on port ${port}`));</pre><p>This will allow our Node API to serve React’s static files while in production mode.</p><p>Finally, create the following Dockerfile to tell Okteto how to build our application:</p><pre>FROM okteto/node:10 as build</pre><pre>WORKDIR /usr/src/app</pre><pre>COPY package.json yarn.lock ./<br>COPY client/package.json client/yarn.lock client/<br>RUN yarn install<br>COPY . . <br>RUN yarn — cwd client build</pre><pre>ENV PORT 8080<br>ENV NODE_ENV production<br>CMD [&quot;node&quot;, &quot;server.js&quot;]</pre><p>With this, we are ready to deploy the production version of our application in Okteto Cloud. Head back to your remote terminal, stop the servers by pressing ctrl+c and exit your development environment. Then, simply run okteto push to push your changes to production.</p><pre>$ okteto push --deploy</pre><pre>i  Development environment deactivated<br>i  Running your build in Okteto Cloud...<br>...<br>...<br>------<br>&gt; importing cache manifest from registry.cloud.okteto.net/rberrelleza/my-app:okteto:<br>------<br>✓  Source code pushed to the development environment &#39;my-app&#39;</pre><p>The okteto push command automatically does everything you need to fully deploy your application in Okteto Cloud. It will: push your code changes to the <a href="https://okteto.com/docs/cloud/build">Okteto Build service</a>, build a new container remotely, tag it, push it to the <a href="https://okteto.com/docs/cloud/registry">Okteto Registry</a> and automatically deploy your application. All of this (and more) in a single command!</p><p>Once the command is finished, go back to your browser and go to Okteto Cloud. You’ll notice that your application no longer has an Okteto-green icon. That’s because this is the production version of your application, not just your development environment!</p><h3>Wrapping up</h3><p>In this post we showed you how to build a React + Express app with Okteto Cloud. We talked about the benefits of developing on a fully integrated development environment when compared with just building things locally. Then we talked about how to use Okteto CLI to initialize and deploy your remote development environment. Finally, we walked through how to use the Okteto CLI and the Okteto Build and Registry Services to build, preview and ship your application.</p><p>Okteto Cloud is free for all developers. Get your own account at <a href="https://cloud.okteto.com/">https://cloud.okteto.com</a> and start building your applications today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a85a612a40f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/build-your-react-express-app-in-okteto-cloud-a85a612a40f6">Build your React + Express App in Okteto Cloud</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Develop and Debug ASP.NET Core Applications in Kubernetes]]></title>
            <link>https://medium.com/okteto/how-to-develop-and-debug-asp-net-core-applications-in-kubernetes-e2d1fe62068f?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2d1fe62068f</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Mon, 02 Mar 2020 22:15:33 GMT</pubDate>
            <atom:updated>2020-07-06T02:48:08.311Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7CljdXfYOXxhNKVR.png" /></figure><p><a href="https://kubernetes.io/">Kubernetes</a> is an open-source project for automating deployment, scaling, and management of containers. It has rapidly become the standard to run production workloads and the community around it is just great!</p><p>But developing in Kubernetes presents some challenges. The typical development workflow looks like this: write code, build a Docker image, push it to the registry, redeploy, validate your changes and repeat. This workflow is slow, full of friction, and makes us very unproductive.</p><p>And if you are a Windows .NET developer, then you are well aware that there are major challenges around developing applications that are meant to run in Linux containers in Windows. You can cross compile, you can dual boot, you can use WSL, etc. But those experiences are far from frictionless.</p><p><a href="https://github.com/okteto/okteto">Okteto</a> was created to solve this problem. On this blog post, we will show you how Okteto improves the developer experience in Kubernetes for ASP.NET Core developers. You will be able to take full advantage of using an instant development environment, dependency caching, hot-reloading and VS Code’s remote debugging features while developing your application directly in Kubernetes.</p><h3>Step 1: Deploy the ASP.NET Core Sample App</h3><p>Get a local version of the ASP.NET Sample App by executing the following commands in your local terminal:</p><pre>$ git clone <a href="https://github.com/okteto/aspnetcore-getting-started">https://github.com/okteto/aspnetcore-getting-started</a><br>$ cd aspnetcore-getting-started</pre><p>The k8s.yml file contains the raw Kubernetes manifests to deploy the ASP.NET Core Sample App. Run the application by executing the command below:</p><blockquote><em>You can deploy to your own Kubernetes cluster or give </em><a href="https://okteto.com/"><em>Okteto Cloud</em></a><em> a try. Okteto Cloud is a development platform for Kubernetes applications. Sign up today to get a free developer account with 4CPUs and 8GB of RAM.</em></blockquote><pre>$ kubectl apply -f k8s.yml</pre><pre>deployment.apps “hello-world” created<br>service “hello-world” created</pre><p>This is cool! You typed one command and your application just runs 😎.</p><h3>Step 2: Install the Okteto CLI</h3><p>The <a href="https://github.com/okteto/okteto">Okteto CLI</a> is an open-source project that lets you develop your applications directly in Kubernetes while taking advantage of well-known local tooling. We will use it to speed up our development cycle instead of using the typical development workflow based on building docker images and redeploying containers.</p><p>Install the Okteto CLI:</p><p>MacOS / Linux</p><pre>curl https://get.okteto.com -sSfL | sh</pre><p>Windows:</p><pre>Download https://downloads.okteto.com/cli/okteto.exe and add it to your $PATH.</pre><h3>Step 3: Activate your development container in Kubernetes</h3><p>With the ASP.NET Core sample application deployed, run the following command in your local terminal:</p><pre>$ okteto up</pre><pre> ✓ Development container activated<br> ✓ Files synchronized<br>   Namespace: rberrelleza<br>   Name:      hello-world<br>   Forward:   5000 -&gt; 5000<br>              2222 -&gt; 22</pre><pre>watch : Polling file watcher is enabled<br> watch : Started<br> info: Microsoft.Hosting.Lifetime[0]<br>       Now listening on: <a href="http://0.0.0.0:5000/">http://0.0.0.0:5000</a><br> info: Microsoft.Hosting.Lifetime[0]<br>       Application started. Press Ctrl+C to shut down.<br> info: Microsoft.Hosting.Lifetime[0]<br>       Hosting environment: Development<br> info: Microsoft.Hosting.Lifetime[0]<br>       Content root path: /src</pre><p>The okteto up command starts a <a href="https://okteto.com/docs/reference/development-environment/index.html">Kubernetes development c</a>ontainer, which means:</p><ul><li>The ASP.NET Core Sample App container is updated with the Docker image okteto/hello-world:aspnetcore-dev. This image is based on mcr.microsoft.com/dotnet/core/sdk:3, and is preconfigured with all the required dev tools to build, test, debug and run a dotnetcore-based application. Check the <a href="https://github.com/okteto/aspnetcore-getting-started/blob/master/Dockerfile">Dockerfile</a> to see how it is generated.</li><li>A <a href="https://okteto.com/docs/reference/file-synchronization/index.html">file synchronization service</a> is created to keep your changes up-to-date between your local filesystem and your development container.</li><li>Container port 5000 is forwarded to localhost.</li></ul><p>All of this (and more) can be customized via the okteto.yml <a href="https://okteto.com/docs/reference/manifest/index.html">manifest file</a>.</p><p>To start the application, execute in the Okteto terminal:</p><pre>okteto&gt; dotnet watch run</pre><pre>watch : Polling file watcher is enabled<br>watch : Started<br>info: Microsoft.Hosting.Lifetime[0]<br> Now listening on: <a href="http://localhost:5000/">http://localhost:5000</a><br>info: Microsoft.Hosting.Lifetime[0]<br> Application started. Press Ctrl+C to shut down.<br>info: Microsoft.Hosting.Lifetime[0]<br> Hosting environment: Development<br>info: Microsoft.Hosting.Lifetime[0]<br> Content root path: /okteto</pre><p>Okteto automatically forwards port 5000 from your local computer to the development container, making it accessible via localhost. Test your application by running the command below in a local shell:</p><pre>$ curl localhost:5000</pre><pre>Hello world!</pre><h3>Step 4: Develop directly in Kubernetes</h3><p>Open Controllers/HelloWorldController.cs in your favorite local IDE and modify the response message on line 25 to be <em>Hello world from the cluster!</em>. Save your changes.</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Threading.Tasks;<br>using Microsoft.AspNetCore.Mvc;<br>using Microsoft.Extensions.Logging;</pre><pre>namespace helloworld.Controllers<br>{<br> [ApiController]<br> [Route(“”)]<br> [Route(“[controller]”)]<br> public class HelloWorldController : ControllerBase<br> {<br>    private readonly ILogger&lt;HelloWorldController&gt; _logger;</pre><pre>    public HelloWorldController(ILogger&lt;HelloWorldController&gt; logger)<br>    {<br>      _logger = logger;<br>    }</pre><pre>    [HttpGet]<br>    public string Get()<br>    {<br>      return “Hello world from the cluster!”;<br>    }<br>  }<br>}</pre><p>Take a look at the development container shell and notice how the changes are detected by dotnet watch run and automatically built and reloaded.</p><pre>info: Microsoft.Hosting.Lifetime[0]<br> Application is shutting down…<br>watch : Exited<br>watch : File changed: /src/Controllers/HelloWorldController.cs<br>watch : Started<br>info: Microsoft.Hosting.Lifetime[0]<br> Now listening on: <a href="http://0.0.0.0:5000/">http://0.0.0.0:5000</a><br>info: Microsoft.Hosting.Lifetime[0]<br> Application started. Press Ctrl+C to shut down.<br>info: Microsoft.Hosting.Lifetime[0]<br> Hosting environment: Development<br>info: Microsoft.Hosting.Lifetime[0]<br> Content root path: /src</pre><p>Call your application to see the changes:</p><pre>$ curl localhost:5000</pre><pre>Hello world from the cluster!</pre><p>Notice how your code changes were instantly applied to Kubernetes. No commit, build or push required 😎!</p><p>Every time you make a change in a file, it will be automatically synchronized to your development container, and the process will be hot reloaded automatically. Can you imagine how much more productive this is going to make you?</p><h3>Step 5: Debug directly in Kubernetes</h3><p>Okteto enables you to debug your applications directly from your favorite IDE. For this post, we are going to integrate <a href="https://okteto.com/docs/reference/manifest/#remote-integer-optional">Okteto’s remote mode</a> with vsdbg (the VS dotnet debugger) and VS Code’s remote debugging capabilities.</p><p>For this step, we are going to use the C# extension for VS Code. If you don’t have it, you can <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp#review-details">install it here</a>. You might need to restart your VS Code instance.</p><p>Open HelloWorldController.cs in VS Code, set a breakpoint on line 26 and press F5. VS Code will connect to your development container via SSH and give you a list of processes you can attach to. Scroll through the list, and select the helloworld process, as shown below (you can also type helloworld in the search bar directly).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gePazmmIcfq8M5be.png" /></figure><p>Once you select the process, VS Code will switch to debug view, launch the debugger and attach it to the process you just selected. You’ll know it’s finished when the status bar at the bottom turns orange.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4_YrsPgbQFKeVTiF.png" /></figure><p>Go back to the terminal and call your application again:</p><pre>$ curl localhost:5000</pre><p>As soon as the service receives the request the execution will halt at your breakpoint and VS Code will jump to the front of the screen. You can then inspect the request, the available variables, etc. Your code is executing in your development container in Kubernetes, but you can debug it from your local machine without any extra services or tools. Pretty cool no? 😉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k9ENleVnGrhPR1f-.png" /></figure><h3>How does it works?</h3><p>Your development container is configured to automatically start an SSH server, a port-forward and to add an entry to your local SSH config file when you run okteto up. This allows you to use VS Code to launch a remote debugger securely, so you can develop and debug directly in your development contaainer running in Kubernetes, while coding in your favorite OS and IDE.</p><p>All of this is described via okteto.yml and the launch.json manifests. This way, everyone collaborating in your project will get the <em>exact same configuration</em> by simply running okteto up 🤖.</p><h3>Conclusions</h3><p>In this post, we talked about how you can use Okteto to develop ASP.NET Core applications directly in Kubernetes, independently of your host OS. We showed you how to launch a fully configured remote development environment, how to iterate in your application, and how to validate the changes you make directly in Kubernetes. Finally, we showed you how you can leverage Okteto’s remote mode together with VS Code’s Remote Development extension to create a fully remote development environment directly in your Kubernetes cluster, debugger included!</p><p>Okteto integrates with every stack and runs in any Kubernetes instance. Let us know what you think about it <a href="https://twitter.com/oktetohq">on Twitter</a>, or in <a href="https://kubernetes.slack.com/messages/CM1QMQGS0/">the Okteto channel</a> in the <a href="http://slack.k8s.io/">Kubernetes slack</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2d1fe62068f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/how-to-develop-and-debug-asp-net-core-applications-in-kubernetes-e2d1fe62068f">How to Develop and Debug ASP.NET Core Applications in Kubernetes</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Develop and Debug Python Applications in Kubernetes]]></title>
            <link>https://medium.com/okteto/how-to-develop-and-debug-python-applications-in-kubernetes-4f6bb9cbb74a?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f6bb9cbb74a</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Thu, 30 Jan 2020 18:31:31 GMT</pubDate>
            <atom:updated>2021-06-02T18:55:36.724Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Develop and Debug Python Applications on Kubernetes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jWf1eNxpfKMjx2eU.png" /></figure><p><a href="https://kubernetes.io/">Kubernetes</a> is an open-source project for automating deployment, scaling, and management of containers. It has rapidly become the standard to run production workloads and the community around it is just great!</p><p>But developing on Kubernetes presents some challenges. The typical development workflow looks like this: write code, build a Docker image, push it to the registry, redeploy, validate your changes and repeat. This workflow is slow, and as anti-python as it could be. Python is famous for it’s quick <a href="https://www.freecodecamp.org/news/this-is-why-your-read-eval-print-loop-is-so-amazing-cf0362003983/">Read-Eval-Print loop</a>, after all. We don’t want to give that away when bulding Cloud Native applications.</p><p><a href="https://github.com/okteto/okteto">Okteto</a> was created to solve this problem. On this blog post, we will show you how Okteto improves the developer experience in Kubernetes for Python developers. You will be able to take full advantage of using an instant development environment, dependency caching, hot-reloading and even the PyCharm debugger while developing your application directly on Kubernetes.</p><h3>Step 1: Deploy the Python Sample App</h3><p>Get a local version of the Python Sample App by executing the following commands:</p><pre>$ git clone <a href="https://github.com/okteto/python-getting-started">https://github.com/okteto/python-getting-started</a><br>$ cd python-getting-started</pre><p>The k8s.yml file contains the Kubernetes manifests to deploy the Python Sample App. Run the application by executing:</p><pre>$ kubectl create -f k8s.yml</pre><pre>deployment.apps &quot;hello-world&quot; created<br>service &quot;hello-world&quot; created</pre><blockquote><em>You can deploy to your own Kubernetes cluster or give </em><a href="https://cloud.okteto.com/"><em>Okteto Cloud</em></a><em> a try. Okteto Cloud is a development platform for Kubernetes applications. Sign up today to get a free developer account with 4 CPUs and 8GB of RAM.</em></blockquote><p>This is cool! You typed one command and a dev version of your application just runs 😎.</p><h3>Step 2: Install the Okteto CLI</h3><p>The <a href="https://github.com/okteto/okteto">Okteto CLI</a> is an open-source project that lets you develop your applications directly on Kubernetes while taking advantage of your language’s toolkit. We will use it to speed up our development cycle instead of using the typical development workflow based on building docker images and redeploying containers.</p><p>Install the Okteto CLI (&gt;= 1.12.14):</p><p><strong>MacOS / Linux:</strong></p><pre>$ curl <a href="https://get.okteto.com/">https://get.okteto.com</a> -sSfL | sh</pre><p><strong>Windows:</strong></p><p>Download <a href="https://downloads.okteto.com/cli/okteto.exe">https://downloads.okteto.com/cli/okteto.exe</a> and add it to your <strong>$PATH</strong>.</p><h3>Step 3: Create your okteto manifest</h3><p>To start developing on the Python Sample App you first need to create an okteto manifest.<br>With the Python Sample App deployed, run the following command to create your <a href="https://okteto.com/docs/reference/manifest">okteto manifest</a>:</p><pre>$ okteto init</pre><pre>This command walks you through creating an okteto manifest.<br>It only covers the most common items, and tries to guess sensible defaults.<br>See <a href="https://okteto.com/docs/reference/manifest">https://okteto.com/docs/reference/manifest</a> for the official documentation about the okteto manifest.<br>Use the arrow keys to navigate: ↓ ↑ → ←<br>Select the deployment you want to develop:<br> ▸ hello-world<br> Use default values</pre><p>The okteto init command will scan the available deployments in your Kubernetes namespace and ask you to pick one.<br>Select the hello-world deployment. It’s the one we deployed on the previous step.</p><pre>✓ hello-world<br>✓ Deployment ‘hello-world’ successfully analyzed<br>✓ okteto manifest (okteto.yml) created<br>i Run ‘okteto up’ to activate your development container</pre><p>The okteto init command creates the following okteto.yml file:</p><pre>name: hello-world<br>command: bash<br>volumes:<br> — /root/.cache/pip<br>sync:<br> — .:/usr/src/app<br>forward:<br> — 8080:8080<br>reverse:<br> — 9000:9000</pre><p>This file defines how to activate a development container for the Python Sample App:</p><ul><li>name: the name of the Kubernetes deployment you want to put on development mode.<br>development-environment).</li><li>command: the start command of the development container.</li><li>volumes: a list of paths in your development container to be mounted as persistent volumes. This is useful to persist the pip cache.</li><li>sync: the folders that will be synchronized between your local machine and the development container.</li><li>forward: a list of ports to forward from your development container.</li><li>reverse: a list of ports to reverse forward from your development container to your local machine.</li><li>resources: the resources configuration (CPU and memory) of the development container.</li></ul><p>Also, the okteto init command creates a .stignore file to indicate which files shouldn’t be synchronized to your development container.<br>This is useful to avoid virtual environments, build artifacts or git metadata.</p><h3>Step 4: Activate your development container</h3><p>Next, execute the following command to activate your development container:</p><pre>$ okteto up</pre><pre>✓ Persistent volume successfully attached<br>✓ Images successfully pulled<br>✓ Files synchronized<br> Namespace: default<br> Name: hello-world<br> Forward: 8080 -&gt; 8080<br> Reverse: 9000 &lt;- 9000</pre><pre>Welcome to your development container. Happy coding!<br>default:hello-world app&gt;</pre><p>Working in your development container is the same as working on your local machine.<br>Start the application in development mode by running the following command:</p><pre>default:hello-world app&gt; python app.py</pre><pre>Starting hello-world server…<br> * Serving Flask app “app” (lazy loading)<br> * Environment: development<br> * Debug mode: on<br> * Running on <a href="http://0.0.0.0:8080/">http://0.0.0.0:8080/</a> (Press CTRL+C to quit)</pre><p>Test your application by running the command below in another local shell:</p><pre>$ curl localhost:8080</pre><pre>Hello world!</pre><h3>Step 5: Develop directly on Kubernetes</h3><p>Open the app.py file in your favorite local IDE and modify the response message on line 7 to be <em>Hello world from the cluster!</em>. Save your changes.</p><pre>@app.route(‘/’)<br>def hello_world():<br>    return ‘Hello world from the cluster!’<br>}</pre><p>Okteto will synchronize your changes to your development container.<br>Flask’s auto-reloader will detect the changes automatically and restart the application with the new code.</p><pre>* Detected change in ‘/okteto/app.py’, reloading<br> * Restarting with stat<br>Starting hello-world server…<br> * Debugger is active!<br> * Debugger PIN: 281–298–026</pre><p>Call your application from a local shell to validate the changes:</p><pre>$ curl localhost:8080</pre><pre>Hello world from the cluster!</pre><p>Cool! Your code changes were instantly applied to Kubernetes. No commit, build or push required 😎!</p><h3>Step 6: Debug directly in Kubernetes</h3><p>Okteto enables you to debug your applications directly from your favorite IDE.<br>Let’s take a look at how that works in one of python’s most popular IDE’s, <a href="https://www.jetbrains.com/pycharm/">PyCharm</a>.</p><blockquote>For VS Code users, this <a href="https://code.visualstudio.com/docs/python/debugging#_debugging-by-attaching-over-a-network-connection">document</a> explains how to configure the debugger with <em>debugpy</em>.</blockquote><p>First, open the project in PyCharm, remove the comments on app.py line 20.</p><pre>if __name__ == ‘__main__’:<br> print(‘Starting hello-world server…’)<br> # comment out to use Pycharm’s remote debugger<br> attach()</pre><pre>app.run(host=’0.0.0.0&#39;, port=8080)</pre><p>Second, launch the <a href="https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html">Remote Debug Server</a> by clicking on the Debug button on the top right. Ensure that the Debug Tool Window shows the Waiting for process connection.. message.<br>This message will be shown until you launch your app on the development container shell and it connects to the Debug Server.</p><pre>Starting hello-world server…<br> * Serving Flask app “app” (lazy loading)<br> * Environment: development<br> * Debug mode: on<br> * Running on <a href="http://0.0.0.0:8080/">http://0.0.0.0:8080/</a> (Press CTRL+C to quit)<br> * Restarting with stat<br>Starting hello-world server…<br>Connecting to debugger…</pre><p>On your local machine, switch to the Debug Tool Window. Once the app connects it will show the connection to the pydev debugger.<br>Press the resume button to let the execution continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RIGyCHk8zV3LGaYb.png" /></figure><p>Add a breakpoint on app.py, line 10, and then call your application from your local shell:</p><pre>$ curl localhost:8080</pre><p>The execution will halt at your breakpoint. You can then inspect the request, the available variables, etc. Your code is executing in your development container in Kubernetes, but is being debugged on the local machine. Pretty cool no? 😉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PbRan-IbEaGXf0Qj.png" /></figure><h3>How does it work?</h3><p>The PyCharm project includes a debugging configuration to start the <a href="https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html">remote debug server</a> and to listen for connections on localhost:9000. The Okteto manifest is configured to <a href="https://okteto.com/docs/reference/manifest/index.html#reverse-string-optional">start a reverse tunnel</a> on port 9000 when the development container is activated.</p><p>This way, when the service it’s started in your development container, the connection is sent back to your local machine through the reverse tunnel, where the remote debug server receives and starts the debugging process.</p><p>This configuration allows you debug your application while fully integrated in Kubernetes. And the coolest thing is that since all of this is described in your .idea and Okteto manifests, everyone collaborating in your project will get the <em>exact same configuration</em> by simply running okteto up 🤖.</p><h3>Conclusions</h3><p>Kubernetes has the potential to be a great development platform, providing replicable, resource-efficient and production-like development environments. We have shown you how to use <a href="https://github.com/okteto/okteto">Okteto</a> to create a development workflow that also lets you take advantage of features like incremental builds, debuggers or hot reloads while developing your application directly on Kubernetes.</p><p>Visit our <a href="https://okteto.com/">website</a> to know more about how to improve your team developer productivity with Okteto. Follow us <a href="https://twitter.com/oktetohq">on Twitter</a> and join our <a href="https://kubernetes.slack.com/messages/CM1QMQGS0/">#okteto</a> channel in the <a href="http://slack.k8s.io/">Kubernetes community Slack</a> to share your feedback with our community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f6bb9cbb74a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/how-to-develop-and-debug-python-applications-in-kubernetes-4f6bb9cbb74a">How to Develop and Debug Python Applications in Kubernetes</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Develop and Debug PHP Applications in Kubernetes]]></title>
            <link>https://medium.com/okteto/how-to-develop-and-debug-php-applications-in-kubernetes-ca46560811e?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca46560811e</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Tue, 07 Jan 2020 17:16:45 GMT</pubDate>
            <atom:updated>2021-05-25T21:15:06.724Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4L5bN8qOx_S8DGxZ.png" /></figure><p>If you are building a cloud-based application at scale, running it in <a href="https://kubernetes.io/">Kubernetes</a> is a no-brainer: It’s been adopted by the industry at an incredible rate, it has a wonderful community, and every single cloud vendor offers it as a service.</p><p>But the development experience available when building Kubernetes applications is less than ideal: write your code, build a Docker image, push it to the registry, redeploy, validate your changes and repeat. This flow is not only slow and full of friction but it prevents us from benefiting from PHP’s rich toolkit ecosystem. Think about this for a second. When was the last time that you debug with an actual debugger, instead of adding echos everywhere in your code?</p><p><a href="https://github.com/okteto/okteto">Okteto</a> was created to solve this problem. On this blog post, we will show you how Okteto improves the developer experience in Kubernetes for PHP developers. You will be able to take full advantage of the entire PHP toolkit (debuggers, dependency managers, test frameworks, etc…) while developing your application directly in your cluster.</p><h3>Step 1: Deploy the PHP Sample App</h3><p>For this post, we’ll be using a very simple <a href="https://github.com/okteto/php-getting-started">PHP sample application</a>. Run the command below to get a local clone of it:</p><pre>$ git clone <a href="https://github.com/okteto/php-getting-started">https://github.com/okteto/php-getting-started</a><br>$ cd php-getting-started</pre><p>The k8s.yml file contains the Kubernetes manifests to deploy the application. Run the application by executing:</p><blockquote><em>You can deploy to your own Kubernetes cluster or give </em><a href="https://okteto.com/blog/how-to-develop-aspnetcore-apps-in-kubernetes/www.okteto.com"><em>Okteto Cloud</em></a><em> a try. Okteto Cloud is a development platform for Kubernetes applications. Sign up today to get a free developer account with 4CPUs and 8GB of RAM.</em></blockquote><pre>$ kubectl apply -f k8s.yml</pre><pre>deployment.apps “hello-world” created<br>service “hello-world” created</pre><p>One command and we have the application running. Pretty cool no 😎?</p><h3>Step 2: Install the Okteto CLI</h3><p>The <a href="https://github.com/okteto/okteto">Okteto CLI</a> is an open-source project that lets you develop your applications directly in Kubernetes while taking advantage of well-known local tooling. We will use it to speed up our development cycle instead of using the typical development workflow based on building docker images and redeploying containers.</p><p>Install the Okteto CLI by running the following command:</p><h3>MacOS/Linux</h3><pre>$ curl <a href="https://get.okteto.com/">https://get.okteto.com</a> -sSfL | sh</pre><h3>Windows</h3><pre>$ wget <a href="https://downloads.okteto.com/cli/okteto-Windows-x86_64">https://downloads.okteto.com/cli/okteto-Windows-x86_64</a> -OutFile c:\windows\system32\okteto.exe</pre><h3>Step 3: Create your okteto manifest</h3><p>To start developing on the PHP Sample App you first need to create an okteto manifest.<br>With the PHP Sample App deployed, run the following command to create your <a href="https://okteto.com/docs/reference/manifest">okteto manifest</a>:</p><pre>$ okteto init</pre><pre>This command walks you through creating an okteto manifest.<br>It only covers the most common items, and tries to guess sensible defaults.<br>See <a href="https://okteto.com/docs/reference/manifest">https://okteto.com/docs/reference/manifest</a> for the official documentation about the okteto manifest.<br>Use the arrow keys to navigate: ↓ ↑ → ←<br>Select the deployment you want to develop:<br> ▸ hello-world<br>   Use default values</pre><p>The okteto init command will scan the available deployments in your Kubernetes namespace and ask you to pick one.<br>Select the hello-world deployment. It’s the one we deployed on the previous step.</p><pre>✓ hello-world<br>✓ Deployment ‘hello-world’ successfully analyzed<br>✓ okteto manifest (okteto.yml) created<br>i Run ‘okteto up’ to activate your development container</pre><p>The okteto init command creates the following okteto.yml file:</p><pre>name: hello-world<br>command: bash<br>volumes:<br>  - /root/.composer/cache<br>sync:<br>  - .:/app<br>forward:<br>  - 8080:8080<br>reverse:<br>  - 9000:9000</pre><p>This file defines how to activate a development container for the PHP Sample App:</p><ul><li>name: the name of the Kubernetes deployment you want to put on development mode.</li><li>command: the start command of the development container.</li><li>volumes: a list of paths in your development container to be mounted as persistent volumes. For example, this is useful to persist the Composer cache.</li><li>sync: the folders that will be synchronized between your local machine and the development container.</li><li>forward: a list of ports to forward from your development container.</li><li>reverse: a list of ports to reverse forward from your development container to your local machine</li></ul><p>Also, the okteto init command creates a .stignore file to indicate which files shouldn’t be synchronized to your development container.<br>This is useful to avoid synchronizing binaries, build artifacts, or git metadata.</p><h3>Step 4: Activate your development container in Kubernetes</h3><p>With the application deployed, run the following command:</p><pre>$ okteto up</pre><pre> ✓ Development container activated<br> ✓ Files synchronized</pre><pre>   Namespace: default<br>   Name:      hello-world<br>   Forward:   8080 -&gt; 8080<br>   Reverse:   9000 &lt;- 9000</pre><pre>Welcome to your development container. Happy coding!<br>default:hello-world app&gt;</pre><p>Working in your development container is the same as working on your local machine.<br>Start the application by running the following command:</p><pre>default:hello-world app&gt; php -S 0.0.0.0:8080</pre><pre>[Tue Jan 7 01:54:59 2020] PHP 7.4.1 Development Server (http://0.0.0.0:8080) started</pre><p>Okteto automatically forwards port 8080 from your local computer to the development container, making it accessible via localhost. Test it by running the command below in a local shell:</p><pre>$ curl localhost:8080</pre><pre>Hello world!</pre><h3>Step 5: Develop directly in Kubernetes</h3><p>Open the index.php file in your favorite local IDE nd modify the response message on line 2 to be Hello world from the cluster!. Save your changes.</p><pre>&lt;?php<br>$message = “Hello World from the cluster!”;<br>echo($message);</pre><p>Okteto will synchronize your changes to your development container in Kubernetes, and PHP’s webserver will automatically reload them.</p><p>Call your application from a local shell to test the changes:</p><pre>$ curl localhost:8080</pre><pre>Hello world from the cluster!</pre><p>Cool! Your changes were instantly applied to your application running in Kubernetes. No commit, build or push required 😎!</p><h3>Step 6: Debug directly in Kubernetes</h3><p>Okteto enables you to debug your applications directly from your favorite IDE. Let’s take a look at how that works with <a href="https://www.jetbrains.com/phpstorm/">PHPStorm</a>, one of the most popular IDEs for PHP development.</p><p>If you haven’t already, fire up PHP Storm and load the sample application code there. Once the project is loaded, open index.php and set a breakpoint in line 2. Click on the Start Listen PHP Debug Connections button on the PhpStorm toolbar.</p><p>Go back to your local shell and call the application:</p><pre>$ curl localhost:8080</pre><blockquote><em>If this is the first time you debug this application, the IDE will ask you to confirm the source mapping configuration. Verify the values and click ok to continue.</em></blockquote><p>The execution will halt at your breakpoint. At this point, you are able to inspect the request object, the current values of everything, the contents of $_SERVER variable, etc… Just as you would do if you were debugging locally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oKhH26nAG7ciFb4o.png" /></figure><h3>How does it works?</h3><p>The development container we are using already has PHP7 and XDebug installed. We pre-configured XDebug so that <a href="https://github.com/okteto/devenv/blob/master/php/xdebug.ini#L5">it accepts remote debugging requests</a> on 127.0.0.1:9000. Finally, <a href="https://okteto.com/docs/reference/manifest/index.html#reverse-string-optional">we configured the Okteto manifest</a> to start a reverse tunnel on port 9000.</p><p>This configuration allows you to take advantage of <a href="https://github.com/okteto/devenv/blob/master/php/xdebug.ini#L5">PHPStorm’s Zero Configuration Debugging</a> to make debugging extremely simple. And the coolest thing is that since all of this is described in your Okteto manifest, everyone collaborating in your project will get the <em>exact same configuration</em> by simply running okteto up 🤖.</p><h3>Conclusions</h3><p>Kubernetes has the potential to be a great development platform, providing replicable, resource-efficient and production-like development environments. We have shown you how to use <a href="https://github.com/okteto/okteto">Okteto</a> to create a development workflow that also lets you take advantage of features like hot reloaders or debuggers while developing your application directly in Kubernetes.</p><p>Accelerate your development and start developing directly in Kubernetes today. Let us know what you think about it <a href="https://twitter.com/oktetohq">on Twitter</a>, or in <a href="https://kubernetes.slack.com/messages/CM1QMQGS0/">the Okteto channel</a> in the <a href="http://slack.k8s.io/">Kubernetes slack</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca46560811e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/how-to-develop-and-debug-php-applications-in-kubernetes-ca46560811e">How to Develop and Debug PHP Applications in Kubernetes</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remote Kubernetes Development in Visual Studio Code with Okteto]]></title>
            <link>https://medium.com/okteto/remote-kubernetes-development-in-visual-studio-code-with-okteto-8b96015b41a6?source=rss-9971d092a70c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b96015b41a6</guid>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Ramiro Berrelleza]]></dc:creator>
            <pubDate>Tue, 29 Oct 2019 17:42:18 GMT</pubDate>
            <atom:updated>2020-07-06T02:50:13.374Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*noiL1eBlOXWpxaeh.png" /></figure><p>Microsoft released the <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack">Visual Studio Code Remote Development Extension Pack</a> a few months ago, enabling developers to work with remote development environments directly in Visual Studio Code.</p><p>This new model is very powerful. It lets you use containers (or even entire VMs) as your development environment while still using Visual Code. You can launch fully configurable, replicable and isolated development environments with one command, while getting the full benefit of Visual Studio Code’s features and extensions. I’m a big fan.</p><p>When the extension was launched, we (and a <a href="https://github.com/microsoft/vscode-remote-release/issues/12">few more folks</a>) were a bit disappointed that it didn’t support launching environments in Kubernetes. But it supported SSH, and <a href="https://github.com/okteto/okteto">Okteto</a> was already capable of deploying development environments in Kubernetes. So with a little duct tape and ingenuity, we pretty quickly had our <a href="https://okteto.com/blog/vs-code-remote-development-in-kubernetes/">remote development environments running in Kubernetes</a>.</p><p>We showed our setup to friends and customers, and the overall feedback was great. And now we are ready to share it with everyone. I’m super excited to announce that our new <a href="https://marketplace.visualstudio.com/items?itemName=okteto.remote-kubernetes">Visual Studio Code Remote — Kubernetes</a> extension is now available in the marketplace. Install it and start developing in Kubernetes with Visual Studio Code in seconds.</p><h3>Getting started</h3><p>This post will walk you through creating and connecting to a development environment in Kubernetes using Okteto’s <a href="https://marketplace.visualstudio.com/items?itemName=okteto.remote-kubernetes">Remote — Kubernetes</a> extension. You’ll then create a Go application to show how you can edit and debug code directly from Visual Studio Code, just like you do it locally.</p><h3>Prerequisites</h3><p>To get started, you’ll need to:</p><ul><li>Install (or upgrade) Visual Studio Code 1.39 or newer.</li><li>Install the <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack">Remote — Development</a> extension.</li><li>Have access to a Kubernetes cluster.</li></ul><blockquote><em>You can deploy to your own Kubernetes cluster or give </em><a href="https://okteto.com/blog/how-to-develop-aspnetcore-apps-in-kubernetes/www.okteto.com"><em>Okteto Cloud</em></a><em> a try. Okteto Cloud is a development platform for Kubernetes applications. Sign up today to get a free developer account with 4CPUs and 8GB of RAM.</em></blockquote><h3>Install the extension</h3><p>You can install the Remote - Kubernetes extension <a href="https://marketplace.visualstudio.com/items?itemName=okteto.remote-kubernetes">from the marketplace</a>, or directly from Visual Studio Code’s extension sidebar.</p><p>Once installed, the extension will add the following commands to the command palette:</p><ul><li>Okteto: Down</li><li>Okteto: Create manifest</li><li>Okteto: Install</li><li>Okteto: Up</li></ul><h3>Get the sample application</h3><p>For the purpose of this post, we’ll be using a Go application. You can clone it locally by running the command below.</p><pre>$ git clone <a href="https://github.com/okteto/vscode-remote-go.git">https://github.com/okteto/vscode-remote-go.git</a></pre><p>Start Visual Studio Code, and open the application’s folder.</p><h3>Launch your development environment</h3><p>Open the command palette in Visual Studio Code and type Okteto:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hWyXzvEHAjoI_Srp.png" /><figcaption>Run the Okteto: Up command to get everything started</figcaption></figure><p>Choose the Okteto: Up command, and select the vscode-remote-go/okteto.yml manifest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uJx4ljahDeP2k58A.png" /><figcaption>Select the Okteto manifest</figcaption></figure><blockquote>The okteto.yml manifest tells the extension which image to use for development, the application ports to forward to your local machine, and the working directory of your remote development environment, among <a href="https://okteto.com/docs/reference/manifest/index.html">many other things</a>.</blockquote><p>Once your development environment is provisioned, the extension will launch a pop-up asking you to pick a host. Choose the hello-world.okteto host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bgBIEga08N-nzj3I.png" /><figcaption>Select your remote development environment from the list</figcaption></figure><p>After a few seconds, VS Code will connect over SSH and configure itself. Once it’s finished, you’ll be in an empty window. Click on the Open Folder button and select /okteto. After a few seconds, the remote folder will be loaded:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ifFgR93kiEspJ1QJ.png" /><figcaption>Open the /okteto folder in the remote development environment</figcaption></figure><p>Congratulations, you are now working on your remote development environment in Kubernetes! From this point onward, any actions you perform will happen directly in your Kubernetes development environment.</p><blockquote>The Okteto: Up command launches a development environment in your Kubernetes cluster using the image defined in okteto.yml. It will automatically inject an SSH server into the pod and update your local .ssh/config to integrate with Visual Studio Code’s remote features.</blockquote><h3>Remote development</h3><p>The main benefit of using remote development environments is that you can configure them with the specific dependencies that your application needs without messing up your local environment. In this case, the environment already has go 1.13 installed. You can check by opening a new terminal Terminal &gt; New Terminal (⌃⇧) and running the command below:</p><pre>okteto&gt; go version</pre><pre>go version go1.13.1 linux/amd64</pre><p>First, install the Go extension in your remote environment. Once the extension is installed, press on the reload button to restart the remote Visual Studio Code instance and load the Go extension.This only needs to be done once, since the extensions will be stored in a persistent volume in Kubernetes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GuvhyGDT8BW0YEao.png" /><figcaption>Install the go extension in order to run the application.</figcaption></figure><p>Now let’s start the application. PressF5 (or Debug &gt; Start Debugging) to start the application directly in your development environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MLuxBjX5YH2wR0WT.png" /><figcaption>Go app running in VS Code in a Kubernetes remote environment</figcaption></figure><p>Once the process starts open your browser and navigate to http://localhost:8080 to access the application. You can access it via localhost because the extension is forwarding port 8080 to your local machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*hp7zy73qxCwvusY4.png" /><figcaption>Sample application running in the browser</figcaption></figure><h3>Debug directly in Kubernetes</h3><p>One of the coolest things about Visual Studio Code’s remote extensions, is that you can use all the tools you’re used to directly in your remote development environment, like a linter, or your debugger.</p><p>Starting the application via F5 already started the debugger. Open main.go and add a break point on line 17. Go back to your browser, and reload the request. The execution will halt at your breakpoint. You can then inspect the request, the available variables, etc. Aww yeah 🥳!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7doVqytkHSsi9xX_.png" /><figcaption>Debug directly in Kubernetes without any extra tooling.</figcaption></figure><h3>Shutting it down</h3><p>Once you’re done developing, close the remote instance of Visual Studio Code and run the Okteto: Down command. This will delete the development environment. But don’t worry, all your configurations and extensions are persisted in the cluster.</p><h3>Conclusions</h3><p>The Remote - Kubernetes extension lets you launch replicable development environments directly in Kubernetes, with the extra benefit that you can keep using all the Visual Studio Code extensions. With this, you don’t have to spend time installing dependencies, or configuring your environment. Open Visual Studio Code, run Okteto: Up and you’ll be ready to develop in seconds!</p><p>The sample application used in the post was <a href="https://github.com/okteto/go-getting-started/blob/master/okteto.yml">already configured</a> to work with Okteto and the Remote - Kubernetes extension. To use your own applications, run the Okteto: Create Manifest command to initialize your Okteto manifest, and then Okteto: Up to launch your development environment. Don’t forget to commit the okteto.yml file it to your repository so that the rest of your collaborators can launch their development environments directly in Kubernetes.</p><p>We would ❤️ to hear what you think about remote development and about our new extension. You can reach us <a href="https://twitter.com/oktetohq">on twitter</a>, or in <a href="https://kubernetes.slack.com/messages/CM1QMQGS0/">our channel</a> in the <a href="http://slack.k8s.io/">Kubernetes slack</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b96015b41a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/okteto/remote-kubernetes-development-in-visual-studio-code-with-okteto-8b96015b41a6">Remote Kubernetes Development in Visual Studio Code with Okteto</a> was originally published in <a href="https://medium.com/okteto">Okteto</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>