In my previous article, I introduced Rust, explained how to install it, and created a simple Rust project. With the help of a container and OpenShift's "import from Git" functionality, you can onboard a Rust application onto OpenShift quickly.

[ Keep Rust syntax and tips on hand with this free Rust cheat sheet. ]

You can find the Rust project used in this example in my GitHub repository. The code is based on a repo created by the development team at Actix, a web framework for Rust. The most important files inside the repo include the dockerfile, Cargo.toml, and src/main.rs:

  1. The dockerfile pulls the latest Rust image and runs the cargo build command.
  2. The Cargo.toml file includes the Actix web dependency and package information.
  3. The main.rs script contains the web server code, which displays "Hello, Openshift!" on port 8080.

Onboard Rust using OpenShift Web Console

Rust on OpenShift
  1. Log into the OpenShift Web Console.
  2. Click on Developer on the left sidebar at the very top.
  3. Click the Add button.
  4. Select the Import from Git option.
  5. Add the Git repository URL: https://github.com/nnlama/rust_k8s_webserver
  6. Click Create.

Cargo builds the project in five to 10 minutes. You must have these OpenShift resources:

  • One pod in the completed stage to build the Rust application
  • One pod in the running stage to run the Rust web server
  • One service
  • One route to expose the Rust application

Access the route to the application under the Networking tab on the OpenShift Web Console. Copy and paste the URL into your local browser to see a "Hello OpenShift!" message.

Rust Hello OpenShift success message

Congratulations! You have successfully onboarded your first Rust application on OpenShift. If you are interested in contributing to the Rust community, please visit the Rust Programming Language Handbook and Rustaceans.org for more information on becoming an official Rustacean.


关于作者

Nicole Lama is a first-generation Panamanian-American with a bachelor's in biomedical sciences and a master's in bioinformatics and computational biology. Since 2015, she has worked with academics, tech startups, and Fortune 500 companies to help meet their data extraction, transformation, mobilization, storage, analytics, and visualization needs. She specializes in Python, machine learning, and open source technology. 

UI_Icon-Red_Hat-Close-A-Black-RGB

按频道浏览

automation icon

自动化

有关技术、团队和环境 IT 自动化的最新信息

AI icon

人工智能

平台更新使客户可以在任何地方运行人工智能工作负载

open hybrid cloud icon

开放混合云

了解我们如何利用混合云构建更灵活的未来

security icon

安全防护

有关我们如何跨环境和技术减少风险的最新信息

edge icon

边缘计算

简化边缘运维的平台更新

Infrastructure icon

基础架构

全球领先企业 Linux 平台的最新动态

application development icon

应用领域

我们针对最严峻的应用挑战的解决方案

Virtualization icon

虚拟化

适用于您的本地或跨云工作负载的企业虚拟化的未来