initial commit
20
.gitignore
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# Dependencies
|
||||
/node_modules
|
||||
|
||||
# Production
|
||||
/build
|
||||
|
||||
# Generated files
|
||||
.docusaurus
|
||||
.cache-loader
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM node
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN yarn
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["yarn", "start", "--host", "0.0.0.0"]
|
||||
86
Jenkinfile
Normal file
@ -0,0 +1,86 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
DOCKER_IMAGE = 'jassimsm/documentation'
|
||||
DOCKER_TAG = 'latest'
|
||||
REGISTRY_CREDENTIALS = 'docker-credentials'
|
||||
SSH_CREDENTIALS = 'documentation'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
git 'https://git.tech4biz.wiki/jassim/cicid.git'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install Dependencies') {
|
||||
steps {
|
||||
sh 'yarn install'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Documentation') {
|
||||
steps {
|
||||
sh 'yarn build'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
docker.build("${DOCKER_IMAGE}:${DOCKER_TAG}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
docker.withRegistry('https://index.docker.io/v1/', REGISTRY_CREDENTIALS) {
|
||||
docker.image("${DOCKER_IMAGE}:${DOCKER_TAG}").push()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
script {
|
||||
sshagent(credentials: [SSH_CREDENTIALS]) {
|
||||
sh '''
|
||||
ssh user@160.187.166.47 << EOF
|
||||
docker pull ${DOCKER_IMAGE}:${DOCKER_TAG}
|
||||
docker documentation-container || true
|
||||
docker rm documentation-container || true
|
||||
docker run -d -p 3000:3000 --name documentation-container ${DOCKER_IMAGE}:${DOCKER_TAG}
|
||||
EOF
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Update Nginx Configuration') {
|
||||
steps {
|
||||
script {
|
||||
sshagent(credentials: [SSH_CREDENTIALS]) {
|
||||
sh '''
|
||||
ssh user@160.187.166.47 << EOF
|
||||
sudo nginx -t
|
||||
sudo systemctl reload nginx
|
||||
EOF
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
41
README.md
Normal file
@ -0,0 +1,41 @@
|
||||
# Website
|
||||
|
||||
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
|
||||
|
||||
### Installation
|
||||
|
||||
```
|
||||
$ yarn
|
||||
```
|
||||
|
||||
### Local Development
|
||||
|
||||
```
|
||||
$ yarn start
|
||||
```
|
||||
|
||||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
|
||||
|
||||
### Build
|
||||
|
||||
```
|
||||
$ yarn build
|
||||
```
|
||||
|
||||
This command generates static content into the `build` directory and can be served using any static contents hosting service.
|
||||
|
||||
### Deployment
|
||||
|
||||
Using SSH:
|
||||
|
||||
```
|
||||
$ USE_SSH=true yarn deploy
|
||||
```
|
||||
|
||||
Not using SSH:
|
||||
|
||||
```
|
||||
$ GIT_USER=<Your GitHub username> yarn deploy
|
||||
```
|
||||
|
||||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
|
||||
3
babel.config.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
|
||||
};
|
||||
292
blog/2019-05-29-blog-10.md
Normal file
@ -0,0 +1,292 @@
|
||||
---
|
||||
slug: Installation Guide for LAMP Stack on CentOS 7
|
||||
title: Installation Guide for LAMP Stack on CentOS 7 Linux, Apache, MySQL, PHP
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import apache from '@site/static/img/default_apache.png';
|
||||
import php from '@site/static/img/default_php.png';
|
||||
import todo from '@site/static/img/todo_list.png';
|
||||
|
||||
<div className="head">Introduction</div><br/>
|
||||
<div className="text">A "LAMP" stack is a group of software that works together to enable your computer to host websites and web apps. The term "LAMP" represents Linux (the operating system), Apache (the web server), MariaDB (a place to store website data), and PHP (a language for making websites dynamic).</div><br/>
|
||||
|
||||
<div className="text">On most computers, when we ask for "MySQL," we get MariaDB instead, and that's okay because they're similar. This guide will help you set up the LAMP stack on your computer running CentOS 7. It's like putting together a team to make your websites run smoothly. Let's get started!</div>
|
||||
|
||||
<div className="head">Before You Start</div>
|
||||
<div className="text">Before we dive into the exciting part, make sure you have a special account set up on your computer. We won't be using the root account for this - it's too powerful!</div><br/>
|
||||
|
||||
<div className="text">Don't worry if you haven't set up this special account yet. We have a guide that shows you how to do it. Just follow our step-by-step instructions for setting up your personal space on your CentOS 7 computer. Once you've got that sorted, we'll be all set for the next steps!</div>
|
||||
|
||||
<div className="head">Setting Up Apache - Your Website Host</div>
|
||||
<div className="text">Apache is a friendly host for your website, making it visible to visitors and handling PHP pages.To get Apache, we'll use a special tool on CentOS called "yum." It helps bring things to your computer easily.</div><br/>
|
||||
|
||||
<div className="text">Now, imagine you're talking to your computer. Say, "Hey, computer, I want Apache!" and use this magical command in your terminal:</div>
|
||||
|
||||
<CodeBlock code={`sudo yum install httpd`} /><br/>
|
||||
|
||||
<div clssName="text">When asked, type Y to confirm the Apache installation. After the installation finishes, kick off your Apache server by using this command.</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl start httpd`} /><br/>
|
||||
|
||||
<div clssName="text">To check if your server is working, open your web browser and type in your public IP address or your website's name.</div>
|
||||
|
||||
<div clssName="note"><strong>Note</strong>: If you picked Cloudtopiaa to manage your website's address, just follow the simple instructions in our guides. They'll show you how to create a new website name and connect it to your server hassle-free.</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">After running the command, you'll see a few addresses. Test each one in your web browser to see your server. Another way is to ask another server to tell you your IP address using this command:</div>
|
||||
|
||||
<CodeBlock code={`curl http://icanhazip.com`} /><br/>
|
||||
|
||||
<div className="text">Whatever way you pick, just enter your IP address into your web browser to make sure your server is working.</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_IP_address`} /><br/>
|
||||
|
||||
<div className="text">When you check, you should see a basic web page – that's the default landing page for CentOS 7 Apache.</div>
|
||||
|
||||
<img src={apache} alt="default_apache" />
|
||||
|
||||
<div className="text">To make sure Apache starts automatically when your computer starts up, use this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl enable httpd.service`} /><br/>
|
||||
|
||||
<div className="head">Installing MariaDB for Your Website's Database Management</div>
|
||||
|
||||
<div className="text">Now that your website foundation is set up, let's install MariaDB. It helps manage and store information for your site in organized databases.<br/><br/>To get MariaDB on your system, just run this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo yum install mariadb-server`} /><br/>
|
||||
|
||||
<div className="text">After the installation finishes, kick off MariaDB with this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl start mariadb`} /><br/>
|
||||
|
||||
<div className="text">To make sure MariaDB starts automatically when your computer boots up, use this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl enable mariadb.service`} /><br/>
|
||||
|
||||
<div className="text">To enhance the security of your database server, it's a good idea to use a special script that's already installed with MariaDB. This script will fix some security issues and make sure your database is more protected.</div><br/>
|
||||
|
||||
<div className="text">To start the script, run:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">This script will ask you a few questions to make your MariaDB setup more secure. The first question is about the 'database root password.' It's not the same as your computer's root password. The database root is like a manager with full control over the database. Since you just installed MariaDB and didn't set up a password yet, leave it blank and press ENTER when asked.</div><br/>
|
||||
|
||||
<div className="text">The next question will ask if you want to create a password for the database root. Type N and press ENTER.</div><br/>
|
||||
|
||||
<div className="text">After that, just type Y and press ENTER for the following questions. This will get rid of any unnecessary users and the test database, stop remote root login, and apply these changes right away.</div><br/>
|
||||
|
||||
<div className="text">Once you're done, log in to the MariaDB console by typing:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql`} /><br/>
|
||||
<div className="text">This action links you to the MariaDB server as the main database boss, also known as the 'root' user:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
||||
Your MariaDB connection id is 12
|
||||
Server version: 5.5.68-MariaDB MariaDB Server
|
||||
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
|
||||
|
||||
|
||||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. \
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">For better security, it's a good idea to have separate user accounts with limited access for each database, especially if you have more than one on your server.</div><br/>
|
||||
|
||||
<div className="text">To see how it works, let's make a database called 'example_database' and a user named 'example_user.' You can use different names if you want.</div><br/>
|
||||
|
||||
<div className="text">In your MariaDB console, type the following command to create a new database:</div>
|
||||
|
||||
<CodeBlock code={`CREATE DATABASE example_database;`} /><br/>
|
||||
|
||||
<div className="text">Let's make a new user and give them complete access to the special database you just made. The command below sets the password as 'password,' but make sure to use a strong and secure password of your choice:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`GRANT ALL ON example_database.* TO 'example_user'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;`} /><br/>
|
||||
|
||||
<div className="text">This command ensures that the 'example_user' can do everything with the 'example_database' but won't be able to mess with any other databases on your server.<br/> <br/> After that, use the FLUSH statement to make sure the changes to 'example_user' are saved and take effect:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`FLUSH PRIVILEGES;`} /><br/>
|
||||
|
||||
<div className="text">To leave the MariaDB shell, just type:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">To check if the new user has the right permissions, log back into the MariaDB console, but this time use the 'example_user' details you set up earlier:</div>
|
||||
|
||||
<CodeBlock code={`mysql -u example_user -p`} /><br/>
|
||||
|
||||
<div className="text">Remember the '-p' flag in this command? It'll ask for the password you set when making the 'example_user.' Once you're in the MariaDB console, check if you can access the 'example_database' using this statement:</div>
|
||||
|
||||
<CodeBlock code={`SHOW DATABASES;`} /><br/>
|
||||
|
||||
<div className="text">If everything went well, you should see 'example_database' in the output:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+--------------------+
|
||||
| Database |
|
||||
+--------------------+
|
||||
| example_database |
|
||||
| information_schema |
|
||||
+--------------------+
|
||||
2 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To leave the MariaDB shell, just type:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Your database is all set, and now you can move on to installing PHP.</div>
|
||||
|
||||
<div className="head">Adding PHP for Interactive Website Content</div>
|
||||
|
||||
<div className="text">Now that you have Apache for showing your website and MariaDB for storing data, let's add PHP to make your site interactive. PHP processes code to show dynamic content. You'll also need 'php-mysql' to make PHP talk to MySQL databases. No worries about the core PHP packages; they'll be installed automatically.</div>
|
||||
|
||||
<div className="text">Just use this command to get both 'php' and 'php-mysql' packages with yum:</div>
|
||||
|
||||
<CodeBlock code={`sudo yum install php php-mysql`} /><br/>
|
||||
|
||||
<div className="text">After installing PHP, restart the Apache web server so that it recognizes the new PHP module you just added:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl restart httpd.service`} /><br/>
|
||||
|
||||
<div className="text">Your server is now set up with everything needed for your LAMP stack application. The next thing to do is to check if everything is working well together.</div>
|
||||
|
||||
<div className="head">Checking PHP on Your Apache Web Server</div>
|
||||
|
||||
<div className="text">The initial setup of Apache on CentOS 7 puts the main folder for your website at /var/www/html. You don't have to tweak any Apache settings for PHP to work correctly.</div><br/>
|
||||
|
||||
<div className="text">But, if you want to make things easier, you can change the permission settings on that folder. This way, you can create and edit files in that directory without needing to use 'sudo' every time.</div><br/>
|
||||
|
||||
<div className="text">Run the following command to change the owner of the default Apache folder to a user and group named 'sammy.' Just replace 'sammy' with your own username and group:</div>
|
||||
|
||||
<CodeBlock code={`sudo chown -R sammy.sammy /var/www/html/`} /><br/>
|
||||
|
||||
<div className="text">To check if your web server is working correctly, let's create a PHP test file. You can use any text editor you like. In the examples below, we'll use the default 'vi' text editor in CentOS 7.</div><br/>
|
||||
|
||||
<div className="text">Make a new PHP file called 'info.php' in the 'var/www/html' directory:</div>
|
||||
|
||||
<CodeBlock code={`vi /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">This will open an empty PHP file in the 'var/www/html' directory. Press 'I' to start typing and making changes. Now, enter the following PHP code:</div>
|
||||
|
||||
<CodeBlock code={`<?php phpinfo(); ?>`} /><br/>
|
||||
|
||||
<div className="text">This PHP code shows details about the PHP setup on your server. After editing, press 'ESC' to exit insert mode in vi. Then type ':x' to save and close the file</div><br/>
|
||||
|
||||
<div className="text">To check if your web server can display PHP content correctly, go to your server's public IP address followed by '/info.php' in a web browser</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_IP_address/info.php`} /><br/>
|
||||
|
||||
<div className="text">When you open your web browser and go to your server's public IP address followed by '/info.php', you'll see a page that looks like the one below:</div><br/>
|
||||
|
||||
<img src={php} alt="default_php" /><br/>
|
||||
|
||||
<div className="text">This page shows information about your server from the PHP perspective. It's helpful for solving problems and making sure your settings are correct. When you're finished, it's a good idea to delete this file because it contains sensitive information about your PHP and CentOS setup.<br/> <br/>
|
||||
To get rid of the file, you can use 'rm':</div>
|
||||
|
||||
<CodeBlock code={`rm /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">You can save this page so you can come back to it later if you need the information again. Next, you can check if the database is working properly using PHP.</div><br/>
|
||||
|
||||
<div className="head">Checking Database Connection with PHP (Optional)</div>
|
||||
<div className="text">To see if PHP is correctly connecting to MariaDB and performing database operations, you can create a test table with some example data. Afterward, you can ask PHP to retrieve and display the contents of that table.</div><br/>
|
||||
<div className="text">Begin by accessing the MariaDB console using the username and password you set up earlier:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`mysql -u example_user -p`} /><br/>
|
||||
|
||||
<div className="text">In the MariaDB console, enter the following command to create a table called "todo_list" in your "example_database":</div>
|
||||
|
||||
<CodeBlock code={`CREATE TABLE example_database.todo_list (
|
||||
item_id INT AUTO_INCREMENT,
|
||||
content VARCHAR(255),
|
||||
PRIMARY KEY(item_id)
|
||||
);
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The MariaDB console will let you know about any changes made to your table after each update:</div>
|
||||
<CodeBlock code={`Query OK, 0 rows affected (0.00 sec)`} /><br/>
|
||||
|
||||
<div className="text">Add some information into the test table. You can use the following command multiple times, changing the values each time, to fill up your test table:</div>
|
||||
|
||||
<CodeBlock code={`INSERT INTO example_database.todo_list (content) VALUES ("My first important item");`} /><br/>
|
||||
|
||||
<div className="text">To make sure that the information was saved correctly in your table, execute the following command:</div>
|
||||
|
||||
<CodeBlock code={`SELECT * FROM example_database.todo_list;`} /><br/>
|
||||
|
||||
<div className="text">Here's what an example of the result might look like:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+---------+--------------------------+
|
||||
| item_id | content |
|
||||
+---------+--------------------------+
|
||||
| 1 | My first important item |
|
||||
| 2 | My second important item |
|
||||
| 3 | My third important item |
|
||||
| 4 | and this one more thing |
|
||||
+---------+--------------------------+
|
||||
4 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Once you've checked that your test table has the right information, you can leave the MariaDB console:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a PHP script to connect to MariaDB and get your data. Open a new PHP file in your web folder using your favorite text editor. If you like, you can use vi as shown in this example:</div>
|
||||
|
||||
<CodeBlock code={`vi /var/www/html/todo_list.php`} /><br/>
|
||||
|
||||
<div className="text">To add the following content, follow these steps in the vi text editor:</div>
|
||||
|
||||
<div className="text"><ol><li>Press the "I" key to enter insert mode.</li><li>Replace "example_user" and "password" with your actual database username and password.</li></ol></div>
|
||||
|
||||
<div className="text">After making these changes, the content will be added to the file.</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
$user = "example_user";
|
||||
$password = "password";
|
||||
$database = "example_database";
|
||||
$table = "todo_list";
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
|
||||
echo "<h2>TODO</h2><ol>";
|
||||
foreach($db->query("SELECT content FROM $table") as $row) {
|
||||
echo "<li>" . $row['content'] . "</li>";
|
||||
}
|
||||
echo "</ol>";
|
||||
} catch (PDOException $e) {
|
||||
print "Error!: " . $e->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">To save and exit the file in vi:Press the "Esc" key to exit insert mode. Type ":x" (without quotes) and press Enter.</div>
|
||||
<div className="text">Once you've saved and closed the file, you can view this page in your web browser by going to your server's hostname or public IP address, followed by "/todo_list.php".</div>
|
||||
|
||||
<CodeBlock code={`http://server_host_or_IP/todo_list.php`} /><br/>
|
||||
|
||||
<div className="text">Here's what the web page might look like, showing the information you added to your test table:</div><br/>
|
||||
|
||||
|
||||
<img src={todo} alt="todo_list" /><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">In this guide, you've created a strong base for hosting PHP websites and apps for your visitors, using Apache as your web server. You've configured Apache to work with PHP and set up a MariaDB database to store your website's information.</div> <br/>
|
||||
|
||||
|
||||
<div className="text"><strong>Ready to start building your own website? Let's get started!</strong></div>
|
||||
121
blog/2019-05-29-blog-11.md
Normal file
@ -0,0 +1,121 @@
|
||||
---
|
||||
slug: Building Your Web Server Installing Apache
|
||||
title: Building Your Web Server Installing Apache, MySQL, PHP (LAMP) Stack on Ubuntu 12.04
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
<div className="head">What is LAMP?</div>
|
||||
|
||||
<div className="text">LAMP stack is a bundle of free software that helps set up web servers. The name stands for Linux, Apache, MySQL, and PHP. Since your virtual private server is already using Ubuntu (which is a type of Linux), you've got one part covered. Now, let's see how to install the rest.</div>
|
||||
|
||||
<div className="head">Getting Started</div>
|
||||
|
||||
<div className="text">To follow this tutorial, you'll need to have administrator access on your VPS. If you're unsure how to set this up, check out the "Initial Server Setup" guide for instructions on getting started.</div>
|
||||
|
||||
<div className="head">Setting Up Apache</div>
|
||||
<div className="text">Apache is a popular, free software used to run many websites.</div><br/>
|
||||
|
||||
<div className="text">To install Apache, follow these steps:</div>
|
||||
<div className="text"><ol><li>Open the terminal on your computer.</li><li>Type in the following commands:</li></ol></div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get update sudo apt-get install apache2`} /><br/>
|
||||
|
||||
<div className="text">That's all there is to it! To make sure Apache is installed correctly, just open your web browser and enter your server's IP address (e.g., http ://12.34.56.789). If everything's set up right, you'll see a page with the words "It works!" on it.</div>
|
||||
|
||||
|
||||
<div className="head">How to Check Your Server's IP Address</div>
|
||||
<div className="text">To find out your server's IP address, you can use the following command:</div>
|
||||
|
||||
<CodeBlock code={`ifconfig eth0 | grep inet | awk '{ print $2 }'`} /><br/>
|
||||
|
||||
<div className="head">MySQL Setup</div>
|
||||
|
||||
<div className="text">MySQL is a system that helps you manage your data, making it easier to organize and find information.</div><br/>
|
||||
|
||||
<div className="text">To install MySQL, follow these steps in your terminal:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql`} /><br/>
|
||||
|
||||
<div className="text">After the installation, MySQL will prompt you to set a root password. If you didn't set the password during the installation, don't worry. You can easily set it later from inside the MySQL shell.</div>
|
||||
|
||||
<div className="text">Once MySQL is installed, let's activate it with this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_install_db`} /><br/>
|
||||
|
||||
<div className="text">To complete the process, run the MySQL setup script:</div>
|
||||
|
||||
<CodeBlock code={`sudo /usr/bin/mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">You'll be asked to enter your current root password.
|
||||
Just type it in.</div>
|
||||
|
||||
<div className="text">Enter current password for root (enter for none): OK, successfully used password, moving on…</div>
|
||||
|
||||
<div className="text">Next, the prompt will inquire if you wish to change the root password. Select "N" to keep the current password and proceed to the following steps.</div><br/>
|
||||
|
||||
<div className="text">It's simplest to say "Yes" to all the options. Once you've done that, MySQL will reload and apply the updates.</div>
|
||||
|
||||
<CodeBlock code={`By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up...`} /><br/>
|
||||
|
||||
<div className="text">After completing those steps, you can wrap up by installing PHP.</div>
|
||||
|
||||
|
||||
<div className="head">Getting PHP installed</div>
|
||||
<div className="text">PHP is an open source web scripting language that is widely used to build dynamic web pages.<br/> To add PHP to your system, open your terminal and type in this command.</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt`} /><br/>
|
||||
|
||||
<div className="text">Once you've confirmed "yes" to the prompt twice, PHP will install itself automatically.</div><br/>
|
||||
|
||||
<div className="text">You might also want to include PHP in the directory index, so it can serve the appropriate PHP index files:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/mods-enabled/dir.conf`} /><br/>
|
||||
|
||||
<div className="text">Make sure to include "index.php" at the start of your index files. Your page should now appear like this:</div>
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c> DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule>`} /><br/>
|
||||
|
||||
<div className="head">PHP Extensions</div>
|
||||
<div className="text">In addition to its core functionality, PHP offers various libraries and extensions that you can install on your virtual server. You can view the available extensions to enhance PHP's capabilities.</div>
|
||||
|
||||
<CodeBlock code={`apt-cache search php5-`} /><br/>
|
||||
|
||||
<div className="text">The terminal will show you a list of modules you can choose from. It will look something like this:</div>
|
||||
|
||||
<CodeBlock code={`php5-cgi - server-side, HTML-embedded scripting language (CGI binary) php5-cli - command-line interpreter for the php5 scripting language php5-common - Common files for packages built from the php5 source php5-curl - CURL module for php5 php5-dbg - Debug symbols for PHP5 php5-dev - Files for PHP5 module development php5-gd - GD module for php5 php5-gmp - GMP module for php5 php5-ldap - LDAP module for php5 php5-mysql - MySQL module for php5 php5-odbc - ODBC module for php5 php5-pgsql - PostgreSQL module for php5 php5-pspell - pspell module for php5 php5-recode - recode module for php5 php5-snmp - SNMP module for php5 php5-sqlite - SQLite module for php5 php5-tidy - tidy module for php5 php5-xmlrpc - XML-RPC module for php5 php5-xsl - XSL module for php5 php5-adodb - Extension optimising the ADOdb database abstraction library php5-auth-pam - A PHP5 extension for PAM authentication [...]`} /><br/>
|
||||
|
||||
<div className="text">When you've chosen the module you want to install, type the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install name of the module`} /><br/>
|
||||
|
||||
<div className="text">You can install multiple libraries simultaneously by listing each module's name with a space in between.</div> <br/>
|
||||
|
||||
<div className="text">Great job! Your droplet now has a fully functional LAMP stack!</div>
|
||||
|
||||
<div className="head">Your PHP server's results - Viewing PHP</div>
|
||||
<div className="text">Even though LAMP is installed, let's confirm by creating a simple PHP info page.
|
||||
To do this, start by making a new file:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /var/www/info.php`} /><br/>
|
||||
|
||||
<div className="text">Now, include the following line:</div>
|
||||
|
||||
<CodeBlock code={`<?php phpinfo(); ?>`} /><br/>
|
||||
|
||||
<div className="text">After that, save your changes and close the file.<br/><br/>
|
||||
Next, restart Apache to make sure all the changes are applied:</div>
|
||||
|
||||
<CodeBlock code={`sudo service apache2 restart`} /><br/>
|
||||
|
||||
<div className="text">Finally, open your web browser and go to your PHP info page. Make sure to replace "12.34.56.789" with the correct IP address of your server: http://your_server_ip_address/info.php</div><br/>
|
||||
|
||||
<div className="con">Conclusion -</div>
|
||||
<div className="text">Awesome job! You've built a solid foundation for your website using LAMP on Ubuntu. With Apache for serving pages, MySQL for managing data, and PHP for dynamic content, your server is ready to go. To do even more with your server, you can try adding new features with PHP extensions or explore different tools and frameworks that work well with LAMP.</div><br/>
|
||||
|
||||
<div className="text"><strong>Excited to start creating your website or app? Let's dive in!</strong></div>
|
||||
141
blog/2019-05-29-blog-12.md
Normal file
@ -0,0 +1,141 @@
|
||||
---
|
||||
slug: CentOS 6 Web Server Setup LAMP Stack Installation Guide
|
||||
title: CentOS 6 Web Server Setup LAMP Stack Installation Guide
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
<div className="head">Setting Up Your Website: A Beginner's Guide to LAMP on CentOS</div>
|
||||
|
||||
<div className="text">The LAMP stack is a group of tools used to set up websites. LAMP stands for Linux, Apache, MySQL and PHP.</div>
|
||||
<div className="text"><ol><li>Linux: It's like the foundation of your website. CentOS is already there, serving as the base.</li><li>Apache: Think of Apache as a traffic cop for your website. It directs visitors to the right places.</li><li>MySQL: MySQL is a storage place for your website's information. It keeps everything organized.</li><li>PHP: PHP is a language that helps your website do things – like showing dynamic content.</li></ol></div>
|
||||
|
||||
<div className="text">Since your server is on CentOS, you just need to add Apache, MySQL, and PHP to make your website work.</div>
|
||||
|
||||
<div className="head">Getting Started: Accessing Your Virtual Server</div>
|
||||
|
||||
<div className="text">To follow along with this guide, you need special access to your virtual private server. It's a bit like having a key to your online space. If you're not sure how to get this key, check out the Initial Server Setup Tutorial for simple instructions.</div>
|
||||
|
||||
<div className="head">Step One: Introducing Apache to Your Server</div>
|
||||
|
||||
<div className="text">Let's start by adding Apache to your server. Apache is like a free tool that helps your website be seen by lots of people. To get it, open the terminal and type in this special command:</div>
|
||||
|
||||
<CodeBlock code={`sudo yum install httpd`} /><br/>
|
||||
|
||||
<div className="text">After it's done installing, you can make Apache start working on your online space (VPS):</div>
|
||||
|
||||
<CodeBlock code={`sudo service httpd start`} /><br/>
|
||||
|
||||
<div className="text">All done! To see if Apache is set up, just open your internet browser and go to your server's address (like http ://12.34.56.789). If everything's good, a page saying 'It works!' should show up, just like that!</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Locating Your Server: Finding Its Special Address</div>
|
||||
|
||||
<div className="text">Wondering where to find your server's address? Just use this simple command to uncover it:</div>
|
||||
|
||||
<CodeBlock code={`ifconfig eth0 | grep inet | awk '{ print $2 }'`} /><br/>
|
||||
|
||||
|
||||
<div className="head">Step Two: Bringing in MySQL for Your Website's Data</div>
|
||||
<div className="text">Next up is MySQL, a powerful system that helps keep your website's information organized on your online space. <br/><br/>To get MySQL, go to the terminal and type in these special commands:</div>
|
||||
|
||||
<CodeBlock code={`sudo yum install mysql-server sudo service mysqld start`} /><br/>
|
||||
|
||||
<div className="text">As MySQL installs, it might ask for your permission twice. Just say 'Yes' both times, and MySQL will finish setting up.</div><br/>
|
||||
|
||||
<div className="text">After the installation is complete, you'll get to choose a special password for the main access point, kind of like locking the door to your MySQL space:</div>
|
||||
|
||||
<CodeBlock code={`sudo /usr/bin/mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">The prompt might ask for a password you don't have yet, called the 'root password.'</div><br/>
|
||||
|
||||
<div className="text">Since MySQL is brand new, you can just press 'Enter' without typing anything to leave it empty.</div>
|
||||
|
||||
<CodeBlock code={`Enter current password for root (enter for none): OK, successfully used password, moving on...`} /><br/>
|
||||
|
||||
<div className="text">After that, the system will ask if you want to create a password. Choose 'Y' for 'Yes' and follow what it says.<br/><br/>
|
||||
CentOS makes it easy by asking you simple 'Yes' or 'No' questions.<br/><br/>
|
||||
Just say 'Yes' to everything it asks. When you're done, MySQL will finish up and put all the new stuff in place</div>
|
||||
|
||||
|
||||
|
||||
<CodeBlock code={`By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!`} /><br/>
|
||||
|
||||
<div className="head">Step Three: Bringing in PHP for Dynamic Webpages</div>
|
||||
|
||||
<div className="text">Now, let's add PHP, a tool that helps create dynamic webpages, to your online space.</div><br/>
|
||||
|
||||
<div className="text">To get PHP, go to the terminal and type in this special command:</div>
|
||||
|
||||
<CodeBlock code={`sudo yum install php php-mysql`} /><br/>
|
||||
|
||||
<div className="text">After you say 'Yes' to the PHP question, PHP will finish installing.</div>
|
||||
|
||||
|
||||
|
||||
<CodeBlock code={`Exploring PHP Tools: Libraries and Modules`} /><br/>
|
||||
|
||||
<div className="text">PHP comes with extra tools called libraries and modules that can enhance your server. To see what tools are available, just type.</div>
|
||||
|
||||
<CodeBlock code={`yum search php-`} /><br/>
|
||||
|
||||
<div className="text">After typing that, the terminal will show you a list of different modules. It will look something like this:</div>
|
||||
|
||||
<CodeBlock code={`php-bcmath.x86_64 : A module for PHP applications for using the bcmath library php-cli.x86_64 : Command-line interface for PHP php-common.x86_64 : Common files for PHP php-dba.x86_64 : A database abstraction layer module for PHP applications php-devel.x86_64 : Files needed for building PHP extensions php-embedded.x86_64 : PHP library for embedding in applications php-enchant.x86_64 : Human Language and Character Encoding Support php-gd.x86_64 : A module for PHP applications for using the gd graphics library php-imap.x86_64 : A module for PHP applications that use IMAP`} /><br/>
|
||||
|
||||
|
||||
<div className="text">If you want to know more about what each tool does, type the following command in the terminal. Just replace the name of the tool with the one you're curious about.</div>
|
||||
|
||||
<CodeBlock code={`yum info name of the module`} /><br/>
|
||||
|
||||
<div className="text">If you've chosen a tool you want to add, type the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo yum install name of the module`} /><br/>
|
||||
|
||||
<div className="text">You can add several tools together by typing their names with spaces in between.<br/><br/>
|
||||
Great job! Your online space now has the complete LAMP stack!<br/><br/>
|
||||
To make things even easier, let's set it up so that everything starts running automatically when your server starts (PHP will start as soon as Apache does):</div>
|
||||
|
||||
<CodeBlock code={`sudo chkconfig httpd on sudo chkconfig mysqld on`} /><br/>
|
||||
|
||||
|
||||
<div className="head">Step Four: Checking PHP on Your Server</div>
|
||||
<div className="text">Even though LAMP is now installed on your online space, you can still check out its parts by making a simple PHP info page.</div><br/>
|
||||
|
||||
<div className="text">To do this, let's start by creating a new file:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">Now, let's add the following line:</div>
|
||||
|
||||
<CodeBlock code={`<?php phpinfo(); ?>`} /><br/>
|
||||
|
||||
<div className="text">After adding the line, save your work and close the file.<br/><br/>
|
||||
Now, let's make sure all the changes apply to your online space. Restart Apache on your server:</div>
|
||||
|
||||
<CodeBlock code={`sudo service httpd restart`} /><br/>
|
||||
|
||||
<div className="text">To wrap up, check your PHP info page by opening this link in your browser (remember to use your own server's IP address instead of the example): http ://12.34.56.789/info.php</div><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
|
||||
<div className="text">Great job setting up your website base with CentOS 6 and the LAMP stack! You've got the essentials – Apache, MySQL, and PHP – ready for dynamic websites.</div>
|
||||
|
||||
<div className="text"><strong>Ready for more? Explore extra features, keep your server safe and connect with fellow web builders online.</strong></div><br/>
|
||||
|
||||
<div className="text">Keep coding and creating on your CentOS 6 server! Happy coding!</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
414
blog/2019-05-29-blog-13.md
Normal file
@ -0,0 +1,414 @@
|
||||
---
|
||||
slug: Ubuntu 18.04 LAMP Stack Setup Step-by-Step Guide
|
||||
title: Ubuntu 18.04 LAMP Stack Setup Step-by-Step Guide
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import ubuntu from '@site/static/img/small_apache_default.png';
|
||||
import lamp from '@site/static/img/LampStack.jpg';
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
<div className="text">Think of a 'LAMP' stack like a group of helpful computer tools that work together to create awesome websites. Let's meet the team:</div>
|
||||
<div className="text"><ol><li>L for Linux: This is like the computer's main system.</li><li>A for Apache: Meet the web server, it helps people see your website.</li><li>M for MySQL: Imagine this as a smart storage space where your website keeps important things.</li><li>P for PHP: This is the creative part that makes your website do cool and interesting stuff.</li></ol></div>
|
||||
|
||||
<div className="text">Now, we're going to set up this friendly team on a computer using Ubuntu 18.04. Ready to get started?</div><br/>
|
||||
|
||||
<div className="head">What You Need Before We Begin</div>
|
||||
<div className="text">Before we start, make sure you have a special kind of computer called an 'Ubuntu 18.04 server.' Also, you'll need a special account on that computer that can do important things, like installing stuff. We'll guide you on how to set this up in an easy way. Let's get started!</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Step 1: Installing Apache and Setting Up the Firewall</div>
|
||||
|
||||
<div className="text">Apache is a common web server used to host websites. It works great with PHP to make dynamic websites. Let's get it installed and make sure our computer's security is set up.</div>
|
||||
|
||||
<div className="text">Start by making sure your computer has the latest updates by typing:</div>
|
||||
<CodeBlock code={`sudo apt update`} /><br/>
|
||||
|
||||
<div className="text">If it's your first time using 'sudo' today, it might ask for your usual computer password to make sure you're allowed to do special things.</div>
|
||||
|
||||
<div className="text">After updating, let's get Apache installed. Just type:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install apache2`} /><br/>
|
||||
|
||||
<div className="text">After typing the command, your computer will tell you about some things it wants to add. It will also say how much space it needs. Just press 'Y' and then 'ENTER' to say 'Yes,' and it will start adding everything.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Making Sure Your Firewall Welcomes Web Traffic</div>
|
||||
<div className="text">Now, let's make sure the security system on your computer is ready to let in web visitors. If you followed our setup guide before, we want to tell it to allow people to see our website.</div><br/>
|
||||
|
||||
<div className="text">Check if the firewall knows about Apache by typing:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app list`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Available applications:
|
||||
Apache
|
||||
Apache Full
|
||||
Apache Secure
|
||||
OpenSSH
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you check the details of the Apache Full profile, you'll find that it allows visitors to come in through ports 80 and 443:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app info "Apache Full"`} /><br/>
|
||||
|
||||
<CodeBlock code={`
|
||||
Output
|
||||
Profile: Apache Full
|
||||
Title: Web Server (HTTP,HTTPS)
|
||||
Description: Apache v2 is the next generation of the omnipresent Apache web
|
||||
server.
|
||||
|
||||
Ports:
|
||||
80,443/tcp
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To let people visit your website, type the following to allow incoming traffic for both regular websites and secure websites:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw allow "Apache Full"`} /><br/>
|
||||
|
||||
<div className="text">To make sure everything is working, open your web browser and visit your computer's special address. If you're not sure what it is, we'll show you how to find it in the next part.</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_ip`} /><br/>
|
||||
|
||||
<div className="text">When you open the web browser, you might see a page that comes with Ubuntu 18.04 and Apache. Don't worry, it's just there to show things are working fine. It should look a bit like this:</div>
|
||||
|
||||
<img src={ubuntu} alt="small_apache_default" />
|
||||
<div className="text">If this page shows up, it means your web server is set up properly and can be reached through the firewall.</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Finding Your Server's Public IP Address</div>
|
||||
|
||||
<div className="text">If you're not sure about your server's special address that everyone can use to connect to it, don't worry. We'll show you a few easy ways to find it. This address is usually what you use to talk to your server through SSH.</div><br/>
|
||||
|
||||
<div className="text">One way to find it is by using some simple commands. Let's start with this one:</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">After typing the command, you'll get a couple of lines. Each line is a correct address, but your computer might only use one of them. You can try each one to see which works.</div><br/>
|
||||
|
||||
<div className="text">Another way is to use a special tool called 'curl' to ask an external friend what address it sees for your server. It's like getting a second opinion. Let's try this:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install curl
|
||||
curl http://icanhazip.com
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">No matter how you found your special address, just type it into the top bar of your web browser. This will show you the default Apache page and confirm everything is working fine.</div><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Step 2: Setting Up MySQL`} /><br/>
|
||||
|
||||
<div className="text">Now that your web server is ready, let's add MySQL. It's like a smart organizer for your website's information. It stores and helps manage all the data your site needs.</div> <br/>
|
||||
|
||||
<div className="text">Just like before, we'll use 'apt' to get and install MySQL. Ready?</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install mysql-server`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: No need to run 'sudo apt update' again before this command. You already did it earlier when installing Apache. Your computer's list of available software is already updated and ready to go.</div><br/>
|
||||
|
||||
<div className="text">After typing the command, it will show you a list of things it's going to add and how much space they'll take up. Just type 'Y' to keep going.</div><br/>
|
||||
|
||||
<div className="text">Once it's finished installing, let's run a security script that's already included with MySQL. This script helps keep your database safe by fixing some risky settings and making sure only authorized users can access it.</div><br/>
|
||||
|
||||
<div className="text">To start the security script, type:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">It will ask if you want to set up a password-checking tool. This tool helps make sure your passwords are strong and secure.</div>
|
||||
|
||||
<div className="text"> Deciding to turn on this feature is a personal choice. If you enable it, MySQL will reject passwords that aren't very strong, which is good for security. However, it might cause problems if you use certain software, like phpMyAdmin. If you're not sure, it's okay to leave this off. Just make sure to always use strong and unique passwords for your database.</div>
|
||||
|
||||
<CodeBlock code={`Type 'Y' if you want to turn it on, or type anything else if you'd rather continue without enabling it.
|
||||
VALIDATE PASSWORD PLUGIN can be used to test passwords
|
||||
and improve security. It checks the strength of password
|
||||
and allows the users to set only those passwords which are
|
||||
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
|
||||
Press y|Y for Yes, any other key for No:
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you say 'yes,' it will ask you to pick how strict you want the password rules. If you choose the strongest level (entering '2'), it will give you errors if your password doesn't have numbers, both uppercase and lowercase letters, and special characters. So, choose carefully based on how strong you want your passwords to be.</div>
|
||||
|
||||
<CodeBlock code={`There are three levels of password validation policy:
|
||||
LOW Length >= 8
|
||||
MEDIUM Length >= 8, numeric, mixed case, and special characters
|
||||
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
|
||||
|
||||
|
||||
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Whether you chose the password-checking tool or not, your computer will now ask you to pick and confirm a password for the main user of your database (MySQL root user). This user has full control over everything in the database.Even though this user doesn't always need a password, it's a good idea to give one for extra safety. We'll discuss this in a bit.</div><br/>
|
||||
|
||||
<div className="text">If you turned on password checking, it will tell you how strong your password is. Then, it will ask if you want to change it. If you like your password, just type 'N' for 'no' and keep it.</div>
|
||||
|
||||
<CodeBlock code={`Using existing password for root.
|
||||
Estimated strength of the password: 100
|
||||
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">For the other questions, just press 'Y' and then press the ENTER key. This will do a few things like removing some users and a test database, and making sure remote logins aren't allowed for the main user.</div><br/>
|
||||
|
||||
<div className="text">Once you're done, let's check if you can get into the MySQL console by typing:</div>
|
||||
<CodeBlock code={`sudo mysql`} /><br/>
|
||||
|
||||
<div className="text">This will let you into the MySQL server as the main user, which is called 'root.' We're using 'sudo' to do this. You should see something like this after typing the command:</div>
|
||||
<CodeBlock code={`Output
|
||||
Welcome to the MySQL monitor. Commands end with ; or \g.
|
||||
Your MySQL connection id is 5
|
||||
Server version: 5.7.34-0ubuntu0.18.04.1 (Ubuntu)
|
||||
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
|
||||
|
||||
|
||||
Oracle is a registered trademark of Oracle Corporation and/or its
|
||||
affiliates. Other names may be trademarks of their respective
|
||||
owners.
|
||||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
||||
mysql>
|
||||
`} /><br/>
|
||||
|
||||
<CodeBlock code={`To leave the MySQL console, just type:`} /><br/>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Even though you set a password during setup, you didn't need to type it here. That's because the way your computer checks passwords is a bit different for the main user.This might seem odd, but it actually makes things safer. Only users with special access, like you using the console or certain applications, can log in as the main MySQL user. In everyday terms, this means you won't use this user for your regular website. Having a password is still a good idea, just in case things change in the future.</div><br/>
|
||||
|
||||
<div className="text">For better security, it's a good idea to create separate user accounts with limited access for each database you have, especially if you'll have more than one database on your server. You can learn how to do this in our guide: 'Creating a New User and Setting Permissions in MySQL'. It has step-by-step instructions to help you set up MySQL users and manage who can access your databases.</div><br/>
|
||||
|
||||
<div className="text">Now that your MySQL server is set up and safe, let's move on to installing PHP, the last part of the LAMP stack.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Step 3: Adding PHP</div>
|
||||
<div className="text">PHP is like the brain that makes your website do things. It processes code, connects to your databases, and shows dynamic content to visitors.</div><br/>
|
||||
|
||||
<div className="text">Let's use 'apt' again to add PHP. We need three packages: 'php' for PHP itself, 'libapache2-mod-php' to connect PHP with Apache, and 'php-mysql' so PHP can talk to MySQL. Type this command to get them all:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install php libapache2-mod-php php-mysql`} /><br/>
|
||||
|
||||
<div className="text">PHP should install smoothly. We'll check it shortly to make sure everything's working.</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Changing How Apache Shows Directory Contents (Optional)</div>
|
||||
<div className="text">Sometimes, you might want Apache to prioritize certain files when someone visits a directory on your website. By default, Apache looks for an 'index.html' file first. But if you want it to look for 'index.php' files first, we can change that.</div><br/>
|
||||
|
||||
<div className="text">To do this, we'll edit a configuration file called 'dir.conf.' We'll use a simple text editor called 'nano.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/mods-enabled/dir.conf`} /><br/>
|
||||
|
||||
<div className="text">You'll see something like this:</div>
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c>
|
||||
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, take the highlighted 'index.php' and move it to the top of the list, like this:</div>
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c>
|
||||
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">When you're done, press CTRL+X to save and close the file. Confirm by typing 'Y' and pressing ENTER.<br/><br/>
|
||||
Then, restart the Apache web server so it can apply your changes. Just use this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl restart apache2`} /><br/>
|
||||
|
||||
<div className="text">To see if Apache is running okay, you can use the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl status apache2`} /><br/>
|
||||
|
||||
<CodeBlock code={`Sample Output
|
||||
● apache2.service - The Apache HTTP Server
|
||||
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
|
||||
Drop-In: /lib/systemd/system/apache2.service.d
|
||||
└─apache2-systemd.conf
|
||||
Active: active (running) since Thu 2021-07-15 09:22:59 UTC; 1h 3min ago
|
||||
Main PID: 3719 (apache2)
|
||||
Tasks: 55 (limit: 2361)
|
||||
CGroup: /system.slice/apache2.service
|
||||
├─3719 /usr/sbin/apache2 -k start
|
||||
├─3721 /usr/sbin/apache2 -k start
|
||||
└─3722 /usr/sbin/apache2 -k start
|
||||
Jul 15 09:22:59 ubuntu1804 systemd[1]: Starting The Apache HTTP Server...
|
||||
Jul 15 09:22:59 ubuntu1804 apachectl[3694]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' di
|
||||
Jul 15 09:22:59 ubuntu1804 systemd[1]: Started The Apache HTTP Server.
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To exit this status display, simply press the 'Q' key.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Adding Extra Features to PHP (Optional)</div>
|
||||
<div className="text">If you want to do more with PHP, you can add extra modules. To see what's available, use this command:</div>
|
||||
<CodeBlock code={`apt search php- | less`} /><br/>
|
||||
|
||||
<div className="text">You can use the arrow keys to move up and down, and press 'Q' to exit.<br/><br/>
|
||||
These results show extra things you can add to PHP. Each one has a brief explanation.</div>
|
||||
|
||||
<CodeBlock code={`bandwidthd-pgsql/bionic 2.0.1+cvs20090917-10ubuntu1 amd64
|
||||
Tracks usage of TCP/IP and builds html files with graphs
|
||||
bluefish/bionic 2.2.10-1 amd64
|
||||
advanced Gtk+ text editor for web and software development
|
||||
cacti/bionic 1.1.38+ds1-1 all
|
||||
web interface for graphing of monitoring systems
|
||||
ganglia-webfrontend/bionic 3.6.1-3 all
|
||||
cluster monitoring toolkit - web front-end
|
||||
golang-github-unknwon-cae-dev/bionic 0.0~git20160715.0.c6aac99-4 all
|
||||
PHP-like Compression and Archive Extensions in Go
|
||||
haserl/bionic 0.9.35-2 amd64
|
||||
CGI scripting program for embedded environments
|
||||
kdevelop-php-docs/bionic 5.2.1-1ubuntu2 all
|
||||
transitional package for kdevelop-php
|
||||
kdevelop-php-docs-l10n/bionic 5.2.1-1ubuntu2 all
|
||||
transitional package for kdevelop-php-l10n
|
||||
…
|
||||
:
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you want to know more about what a module does, you can search online for information about it. Or, you can see a detailed description of the package by typing:</div>
|
||||
<CodeBlock code={`apt show package_name`} /><br/>
|
||||
|
||||
<div className="text">You'll see a bunch of information. Look for the 'Description' field; it gives a detailed explanation of what each module does.<br/><br/>
|
||||
For instance, to understand the php-cli module, you can type</div>
|
||||
|
||||
<CodeBlock code={`apt show php-cli`} /><br/>
|
||||
|
||||
<div className="text">Among other details, you'll see something like this:</div>
|
||||
<CodeBlock code={`Output
|
||||
…
|
||||
Description: command-line interpreter for the PHP scripting language (default)
|
||||
This package provides the /usr/bin/php command interpreter, useful for
|
||||
testing PHP scripts from a shell or performing general shell scripting tasks.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Ubuntu's default
|
||||
PHP version (currently 7.2).
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you find a package you want to install after researching, you can use the 'apt install' command just like before.<br/><br/>
|
||||
For example, if you want to install php-cli, you would type:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install php-cli`} /><br/>
|
||||
|
||||
<div className="text">If you need to install multiple modules, you can list them all after the 'apt install' command, separated by spaces, like this:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install package1 package2 ...`} /><br/>
|
||||
|
||||
<div className="text">Now that your LAMP stack is set up, it's a good idea to create an Apache virtual host to store your server's configuration details. This helps in managing your website.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Step 4 — Setting Up a Virtual Host for Multiple Domains on Apache</div>
|
||||
<div className="text">Let's create a virtual host to manage configuration details and host multiple domains on your Apache web server. In this guide, we'll use a domain called 'your_domain,' but make sure to replace it with your actual domain name. If you're not sure how to set up a domain with Cloudtopiaa, check our Introduction to Cloudtopiaa DNS guide</div><br/>
|
||||
|
||||
<div className="text">By default, Ubuntu 18.04 comes with one server block that serves content from /var/www/html. While this is fine for a single site, managing multiple sites can get messy. To keep things neat, let’s make a new space for your_domain within /var/www, leaving /var/www/html as the default if no specific site is requested.</div><br/>
|
||||
|
||||
<div className="text">Create the directory for your_domain like this:</div>
|
||||
|
||||
<CodeBlock code={`sudo mkdir /var/www/your_domain`} /><br/>
|
||||
|
||||
<div className="text">Now, let’s make sure the directory is owned by the current user. This is done with the $USER variable, which represents the user currently logged in:</div>
|
||||
|
||||
<CodeBlock code={`sudo chown -R $USER:$USER /var/www/your_domain`} /><br/>
|
||||
<div className="text">To verify the permissions of your web root directory, you can use the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo chmod -R 755 /var/www/your_domain`} /><br/>
|
||||
|
||||
<div className="text">Then, let's create a simple index.html page using the nano text editor or any other editor you prefer:</div>
|
||||
|
||||
<CodeBlock code={`nano /var/www/your_domain/index.html`} /><br/>
|
||||
|
||||
<div className="text">Inside the file, paste the following example HTML code:</div>
|
||||
|
||||
<CodeBlock code={`<html>
|
||||
<head>
|
||||
<title>Welcome to Your_domain!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Success! The your_domain server block is working!</h1>
|
||||
</body>
|
||||
</html>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After you've added the HTML, save the file and close it.</div><br/>
|
||||
<div className="text">To make sure Apache serves this page correctly, we need to create a virtual host configuration file. Instead of changing the default configuration file directly, we'll create a new one specifically for your domain. We'll save it as /etc/apache2/sites-available/your_domain.conf.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/sites-available/your_domain.conf`} /><br/>
|
||||
<div className="text">Next, copy and paste the following configuration block into the file. This block is similar to the default one, but it's tailored for our new directory and domain name.</div>
|
||||
|
||||
<CodeBlock code={`<VirtualHost *:80>
|
||||
ServerAdmin webmaster@localhost
|
||||
ServerName your_domain
|
||||
ServerAlias www.your_domain
|
||||
DocumentRoot /var/www/your_domain
|
||||
ErrorLog $ {APACHE_LOG_DIR}/error.log
|
||||
CustomLog $ {APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Also, note that we've changed the DocumentRoot to our new directory and the ServerAdmin to an email address accessible by the administrator of the your_domain site. Additionally, we've included two directives: ServerName, which sets the base domain for this virtual host, and ServerAlias, which specifies additional names that should match as if they were the base name.</div><br/>
|
||||
|
||||
<div className="text">Once you're done, save and close the file.</div><br/>
|
||||
|
||||
<div className="text">To enable the file, use the command: a2ensite your_domain.conf"</div>
|
||||
|
||||
<CodeBlock code={`sudo a2ensite your_domain.conf`} /><br/>
|
||||
|
||||
<div className="text">Next, let's turn off the default site configuration defined in 000-default.conf:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2dissite 000-default.conf`} /><br/>
|
||||
|
||||
<div className="text">You'll see the following result:</div>
|
||||
<CodeBlock code={`Output
|
||||
Syntax OK
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Restart Apache to make your changes take effect:</div>
|
||||
<CodeBlock code={`sudo systemctl restart apache2`} /><br/>
|
||||
|
||||
<div className="text">You can check if Apache is working with your domain by visiting http://your_domain. If everything is set up correctly, you'll see a page like this:<br/><br/>
|
||||
Now that your virtual host is ready, it's a good idea to test your PHP configuration to ensure everything works smoothly before making further changes or deploying an application.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Testing PHP Setup on Your Web Server</div>
|
||||
<div className="text">To check if PHP is set up correctly, let's create a PHP script called info.php. This file needs to be saved in the web root directory we set up earlier.<br/><br/>
|
||||
Create the file in the web root directory by running:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /var/www/your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">Create a new file by running the command below. This will open a blank file. Copy and paste the following text into the file. This text contains valid PHP code:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
phpinfo();
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After saving and closing the file, it's time to check if your web server can display content generated by the PHP script. To do this, open your web browser and enter the following address into the address bar. You'll need to use your server's public IP address or domain name again.</div><br/>
|
||||
|
||||
<div className="text">Here's the address you should visit:</div>
|
||||
|
||||
<CodeBlock code={`http://your_domain/info.php`} /><br/>
|
||||
<div className="text">The page you'll see should look like this:</div><br/>
|
||||
|
||||
<img src={lamp} alt="LAMP" />
|
||||
|
||||
<div className="text">This page gives you some simple information about your server using PHP. It's handy for checking if everything is set up correctly.</div><br/>
|
||||
|
||||
<div className="text">If you can view this page in your browser, it means PHP is working well.</div><br/>
|
||||
|
||||
<div className="text">Remember to delete this file after testing, as it might share details about your server. To remove it, just use this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo rm /var/www/your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">You can make this page again if you ever need to check your server info in the future.</div><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">Now that you have set up your LAMP stack, you have various options for what to do next. One important step is to make sure that when people visit your website, their connection is secure. This is done through HTTPS. Follow our simple guide on securing your Apache server with Let's Encrypt to add a free security certificate to your site.</div><br/>
|
||||
|
||||
<div className="text">Ready to secure your website? Check out our guide on setting up HTTPS with Let's Encrypt!</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ textAlign: 'center' }}><strong>Secure Your Site Now!</strong>: </div>
|
||||
337
blog/2019-05-29-blog-14.md
Normal file
@ -0,0 +1,337 @@
|
||||
---
|
||||
slug: Deploying a LAMP Environment on Debian 9 Installation Guide
|
||||
title: Deploying a LAMP Environment on Debian 9 Installation Guide
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import debian from '@site/static/img/debian.png';
|
||||
import php from '@site/static/img/php7.0.png';
|
||||
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">Have you ever wondered how websites work? Well, they rely on a special combination of software called a "LAMP" stack. It's like a toolbox for building websites and apps. Let's break it down:</div>
|
||||
|
||||
<div className="text"><ol><li>"L" stands for Linux, which is the operating system that runs the server.</li><li>"A" stands for Apache, which is the software that serves up web pages to visitors.</li><li>"M" stands for MariaDB, which is where all the data for the website is stored.</li><li>"P" stands for PHP, which is a programming language used to create dynamic content on the website.</li></ol></div>
|
||||
|
||||
<div className="text">In this guide, we'll walk you through setting up a LAMP stack on a Debian 9 server. It's easier than it sounds, and by the end, you'll have your own server ready to host websites and apps!</div><br/>
|
||||
|
||||
|
||||
<div className="head">Preparation for Debian 9 LAMP Setup</div>
|
||||
<div className="text">Before we begin, ensure you have the following:</div>
|
||||
<div className="text"><ol><li>A Debian 9 server: This will be your website's home.</li><li>A user account with special permissions: This allows you to make important changes.</li><li>Basic security measures: Protect your server from unauthorized access.</li></ol></div>
|
||||
|
||||
<div className="text">If you're unsure how to set these up, don't worry. We'll guide you through it.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Setting Up Apache and Security</div>
|
||||
<div className="text">Apache is a crucial component for hosting websites. It helps to serve web pages to people when they visit your site. Here's how to get it running on your server:</div><br/>
|
||||
|
||||
<div className="text">First, we need to install Apache. Don't worry, it's easy! We'll use something called "apt" to do this, which is a tool that helps install software on your server. Just follow along with these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt update
|
||||
sudo apt install apache2
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Since this is a special command, you'll need to confirm with your regular password to make sure it's you making the changes.</div><br/>
|
||||
|
||||
<div className="text">Once you've entered your password, it will show you what it's going to do and how much space it will need. Simply type "Y" and then press ENTER to proceed. That's all there is to it!</div><br/>
|
||||
|
||||
<div className="text">Next, if you've already set up the UFW firewall by following the initial server setup instructions, ensure that your firewall lets through traffic for both HTTP and HTTPS.</div><br/>
|
||||
|
||||
<div className="text">When you install UFW on Debian 9, it already has some pre-made settings that you can use to adjust your firewall. You can see all of these settings by running:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app list`} /><br/>
|
||||
|
||||
<div className="text">The WWW profiles help control the ports that web servers use.</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Available applications:
|
||||
. . .
|
||||
WWW
|
||||
WWW Cache
|
||||
WWW Full
|
||||
WWW Secure
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you look at the WWW Full profile, you'll see that it allows traffic to go through ports 80 and 443.</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app info "WWW Full"`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
Profile: WWW Full
|
||||
Title: Web Server (HTTP,HTTPS)
|
||||
Description: Web Server (HTTP,HTTPS)
|
||||
|
||||
Ports:
|
||||
80,443/tcp
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Enable incoming traffic for websites using HTTP and HTTPS on this profile.</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw allow in "WWW Full"`} /><br/>
|
||||
|
||||
<div className="text">You can quickly check if everything worked by opening your web browser and entering your server's public IP address.</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_ip`} /><br/>
|
||||
|
||||
<div className="text">You'll see a page with some information and a test message. This page is provided by Apache on Debian 9 to help you check if everything is set up correctly.</div><br/>
|
||||
|
||||
<img src={debian} alt="Debain" />
|
||||
|
||||
<div className="text">If you can see this page, it means your web server is set up correctly and can be accessed through your firewall.</div><br/>
|
||||
|
||||
<div className="text">If you're not sure what your server's public IP address is, there are a few ways to find it. Usually, it's the same address you use to connect to your server through SSH.</div><br/>
|
||||
|
||||
<div className="text">You can find your IP address using a command in the terminal. One way is to use a tool called "iproute2." Just type this command:</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">When you run the command, you'll get two or three lines back, each showing a different address. They're all correct, but your computer might only be able to use one of them. So, you can try each one to see which works.</div><br/>
|
||||
|
||||
<div className="text">Another way to find your IP address is by using a tool called "curl." This tool contacts another server to ask what your IP address is. Here's how to do it:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install curl
|
||||
curl http://icanhazip.com
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">No matter how you found your IP address, just type it into the address bar of your web browser to see the default Apache page.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Step 2: Configure MariaDB</div>
|
||||
<div className="text">Now that your web server is set up, let's install MariaDB. MariaDB is like a filing cabinet for your website. It stores and manages all the information your site needs.</div><br/>
|
||||
|
||||
<div className="text">In Debian 9, MariaDB is the default database system instead of MySQL. To install it, we'll use a special package called mariadb-server. It's the best way to get MariaDB up and running smoothly.</div><br/>
|
||||
|
||||
<div className="text">Once more, use apt to get and install this software:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install mariadb-server`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: You don't need to run sudo apt update again before this command. You already did it earlier when installing Apache, so your computer's list of available software should be current.</div><br/>
|
||||
|
||||
<div className="text">This command will also show you a list of packages that will be installed and how much space they'll take up. Just type "Y" to continue.</div><br/>
|
||||
|
||||
<div className="text">After the installation is finished, you'll want to run a security script that's already included with MariaDB. This script helps make your database more secure by fixing some settings that might not be safe and restricting access to it. To start the script, just run:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">This will guide you through a series of questions where you can adjust the security settings for your MariaDB installation.The first question will ask you to enter the current database root password. This is like having a master key to access all parts of MariaDB, similar to the administrator account on your computer. Since you've just installed MariaDB and haven't set a password yet, simply press ENTER when prompted.</div><br/>
|
||||
|
||||
<div className="text">The next question will ask if you want to set up a password for the database root. Type "N" for "No" and then press ENTER. In Debian, the root account for MariaDB is closely tied to automated system maintenance. It's important not to change the authentication methods for this account. If you do, it could cause problems with future updates and possibly break the database system. We'll show you later how to set up another administrative account if you need password access for your specific situation.</div><br/>
|
||||
|
||||
<div className="text">After that, you can type "Y" and then press ENTER to stick with the default settings for the rest of the questions. This will remove some anonymous users and a test database, stop remote root logins, and apply these changes right away so MariaDB follows your instructions.</div><br/>
|
||||
|
||||
<div className="text">On new installs of Debian systems, the root MariaDB user is set to authenticate using the unix_socket plugin instead of a password by default. This adds some security and convenience in many situations, but it might complicate things if you need to give external programs (like phpMyAdmin) administrative rights.</div><br/>
|
||||
|
||||
<div className="text">Because the root account on the server handles important tasks like managing logs and starting and stopping services, it's not a good idea to change its authentication settings. If you modify the root account credentials in the /etc/mysql/debian.cnf file, it might work at first, but updates could overwrite those changes in the future. Instead, it's recommended to create a new administrative account if you need to use a password for access.</div><br/>
|
||||
|
||||
<div className="text">To do this, we'll create a new account called "admin" with the same privileges as the root account, but set up for password authentication. Here's how: Open the MariaDB prompt in your terminal:</div>
|
||||
|
||||
<CodeBlock code={`sudo mariadb`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a new user with special powers like the root user, but this time with a password. You can choose any username and password you like: <br/>
|
||||
Just follow these steps to create the new user:</div>
|
||||
|
||||
<CodeBlock code={`GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;`} /><br/>
|
||||
|
||||
<div className="text">After creating the new user, we need to make sure the changes are applied right away. To do this, just follow this step:</div>
|
||||
|
||||
<CodeBlock code={`FLUSH PRIVILEGES;`} /><br/>
|
||||
|
||||
<div className="text">Then, exit the MariaDB shell as follows:</div>
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">From now on, whenever you want to use your database with your new administrative user, you'll need to log in as that user using the password you just created. Here's how:</div>
|
||||
|
||||
<CodeBlock code={`mariadb -u admin -p`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Now your database is ready, and you can proceed to install PHP, which is the last part of the LAMP stack.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Step 3: Getting PHP up and running</div>
|
||||
|
||||
<div className="text">PHP is what makes your website dynamic, allowing it to process code and display content based on your needs. It can run scripts, fetch data from your MariaDB databases, and deliver the final content to your web server for display.</div><br/>
|
||||
|
||||
<div className="text">To install PHP, we'll once again use the apt system. This time, we'll also include some helper packages so that PHP can work seamlessly with Apache and communicate with your MariaDB database.</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install php libapache2-mod-php php-mysql`} /><br/>
|
||||
|
||||
<div className="text">PHP installation should go smoothly without any issues. We'll check this soon.</div><br/>
|
||||
|
||||
<div className="text">Usually, you'll want to adjust how Apache serves files when someone asks for a directory on your website. Right now, if someone requests a directory, Apache will look for a file named index.html first. Instead, we want Apache to look for an index.php file first.</div><br/>
|
||||
|
||||
<div className="text">To do this, follow these steps to open the dir.conf file using a text editor with special permissions:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/mods-enabled/dir.conf`} /><br/>
|
||||
|
||||
<div className="text">Here's what it will look like:</div>
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c>
|
||||
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Let's move the PHP index file (highlighted earlier) to the top position after the DirectoryIndex specification, like this:</div>
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c>
|
||||
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you're done, save and close the file by pressing CTRL+X. Confirm the save by typing "Y" and then press ENTER.</div><br/>
|
||||
|
||||
<div className="text">After that, you'll need to restart the Apache web server to apply your changes. Just type this:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl restart apache2`} /><br/>
|
||||
|
||||
<div className="text">You can also see if the Apache web server is running properly by using this command:</div>
|
||||
<CodeBlock code={`sudo systemctl status apache2`} /><br/>
|
||||
|
||||
<CodeBlock code={`Sample Output
|
||||
● apache2.service - The Apache HTTP Server
|
||||
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
|
||||
Active: active (running) since Tue 2018-09-04 18:23:03 UTC; 9s ago
|
||||
Process: 22209 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SUCCESS)
|
||||
Process: 22216 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
|
||||
Main PID: 22221 (apache2)
|
||||
Tasks: 6 (limit: 4915)
|
||||
CGroup: /system.slice/apache2.service
|
||||
├─22221 /usr/sbin/apache2 -k start
|
||||
├─22222 /usr/sbin/apache2 -k start
|
||||
├─22223 /usr/sbin/apache2 -k start
|
||||
├─22224 /usr/sbin/apache2 -k start
|
||||
├─22225 /usr/sbin/apache2 -k start
|
||||
└─22226 /usr/sbin/apache2 -k start
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To add more features to PHP, you can install extra modules. To see what modules and libraries are available, you can use a command called "apt search" along with a tool called "less" that lets you scroll through the list easily. Here's how:</div>
|
||||
|
||||
<CodeBlock code={`apt search php- | less`} /><br/>
|
||||
|
||||
<div className="text">You can use the arrow keys to move up and down the list, and press the "Q" key when you're done looking.</div><br/>
|
||||
|
||||
<div classname="text">These results show extra things you can add to PHP if you want. Each one comes with a brief description to help you understand what it does.</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
Sorting...
|
||||
Full Text Search...
|
||||
bandwidthd-pgsql/stable 2.0.1+cvs20090917-10 amd64
|
||||
Tracks usage of TCP/IP and builds html files with graphs
|
||||
|
||||
bluefish/stable 2.2.9-1+b1 amd64
|
||||
advanced Gtk+ text editor for web and software development
|
||||
|
||||
cacti/stable 0.8.8h+ds1-10 all
|
||||
web interface for graphing of monitoring systems
|
||||
|
||||
cakephp-scripts/stable 2.8.5-1 all
|
||||
rapid application development framework for PHP (scripts)
|
||||
|
||||
ganglia-webfrontend/stable 3.6.1-3 all
|
||||
cluster monitoring toolkit - web front-end
|
||||
|
||||
haserl/stable 0.9.35-2+b1 amd64
|
||||
CGI scripting program for embedded environments
|
||||
|
||||
kdevelop-php-docs/stable 5.0.3-1 all
|
||||
transitional package for kdevelop-php
|
||||
|
||||
kdevelop-php-docs-l10n/stable 5.0.3-1 all
|
||||
transitional package for kdevelop-php-l10n
|
||||
…
|
||||
:
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To find out more about what each module does, you can search online for more information. Alternatively, you can see a detailed description of the package by typing:</div>
|
||||
|
||||
<CodeBlock code={`apt show package_name`} /><br/>
|
||||
|
||||
<div className="text">You'll see a lot of information, including a field called "Description" that provides a detailed explanation of what each module does.</div><br/>
|
||||
|
||||
<div className="text">For instance, if you want to know what the "php-cli" module does, you can type:</div>
|
||||
|
||||
<CodeBlock code={`apt show php-cli`} /><br/>
|
||||
|
||||
<div className="text">In addition to a bunch of other details, you'll come across something like this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
…
|
||||
Description: command-line interpreter for the PHP scripting language (default)
|
||||
This package provides the /usr/bin/php command interpreter, useful for
|
||||
testing PHP scripts from a shell or performing general shell scripting tasks.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you find a program you want to add to your computer, you can use a command called 'apt install' to do it, just like you did before.</div><br/>
|
||||
|
||||
<div className="text">For example, if you think you need something called 'php-cli,' you can type:</div><br/>
|
||||
|
||||
<CodeBlock code={`sudo apt install php-cli`} /><br/>
|
||||
|
||||
<div classname="text">If you want to add multiple programs at the same time, you can do it by writing down the names of each program with a space between them. Just like before, use the 'apt install' command, and list the names of the programs you want to install, like this:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install package1 package2 …`} /><br/>
|
||||
|
||||
<div className="text">Now that you've set up your LAMP stack, it's a good idea to check if everything is working smoothly with PHP. This way, you can catch and fix any problems before you make more changes or try running an application. Let's test your PHP configuration to make sure everything is okay.</div><br/>
|
||||
|
||||
<div className="head">Step 4 — Running PHP on your web server and testing it</div>
|
||||
|
||||
<div className="text">Now, let's check if PHP is set up correctly on your system by creating a simple PHP script. We'll call it 'info.php.' To make sure Apache can find and show this file, we need to save it in a specific folder called the 'web root.'</div><br/>
|
||||
|
||||
<div className="text">Now, let's check if PHP is set up correctly on your system by creating a simple PHP script. We'll call it 'info.php.' To make sure Apache can find and show this file, we need to save it in a specific folder called the 'web root.'</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">Once the blank file opens, let's add some code to make it a valid PHP file. Copy and paste the following text into the file. This code is what PHP understands and can execute:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
phpinfo();
|
||||
?>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After you've added the code, save the changes and close the file.</div><br/>
|
||||
|
||||
<div className="text">Now, let's see if your web server can show the result of the PHP script. To do this, open your web browser and go to a specific page. You'll need to use your server's public IP address again.</div><br/>
|
||||
|
||||
<div className="text">The page you want to visit is:</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_ip/info.php`} /><br/>
|
||||
|
||||
<div className="text">When you go to the page in your web browser, it should look something like this:</div><br/>
|
||||
|
||||
<img src={php} alt="php7.0" />
|
||||
|
||||
<div className="text">This page shows basic information about your server using PHP. It's helpful for checking if everything is set up correctly.</div><br/>
|
||||
|
||||
<div className="text">If you can view this page in your browser, it means PHP is working as it should.</div><br/>
|
||||
<div className="text">However, it's a good idea to delete this file after testing because it might share information about your server with unauthorized users. To remove it, just type the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo rm /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">If you ever need the information on this page again, don't worry! You can always recreate it. For now, it's a good practice to remove the page to keep your server secure. If you ever need it in the future, you can easily make it again.</div><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">Now that you have your LAMP stack ready, you're like a superhero with the power to create all sorts of websites and cool things on your computer!</div><br/>
|
||||
|
||||
<div className="text" style={{ textAlign: 'center' }}><strong>Feeling excited? </strong></div><br/>
|
||||
|
||||
<div className="text" style={{ textAlign: 'center' }}><strong>How about checking out some fun websites or even trying to make your very own? </strong></div><br/>
|
||||
|
||||
<div className="text">There are so many cool things you can do! If you ever get stuck or need some help, just ask and we're here for you!</div>
|
||||
224
blog/2019-05-29-blog-15.md
Normal file
@ -0,0 +1,224 @@
|
||||
---
|
||||
slug: Easy Installation Guide Building Your Website with LAMP Stack on Debian 8
|
||||
title: Easy Installation Guide Building Your Website with LAMP Stack on Debian 8
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack'
|
||||
import debian from '@site/static/img/debian.png';
|
||||
import php from '@site/static/img/php5.6.9.png';
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">The LAMP stack is like a super toolbox for building websites and apps. It's made up of Linux (the operating system), Apache (the web server), MySQL (a database), and PHP (a scripting language). When you put all these tools together, your computer becomes a superhero that can host cool and dynamic websites.</div><br/>
|
||||
|
||||
<div className="text">In this guide, we'll help you set up the LAMP stack on a Debian 8 server. Let's get started!</div><br/>
|
||||
|
||||
<div className="head">Debian 8 Setup Guide</div>
|
||||
|
||||
<div className="text">Before we start, make sure you have a Debian 8 server and a special user account that can do important things (we call it 'sudo-enabled'). If you haven't set this up yet, no worries! Just check out our simple guide at the beginning.</div><br/>
|
||||
|
||||
<div className="text">Also, it's like putting a protective shield around your server by creating a basic firewall. We'll show you how to do that in an easy step-by-step tutorial. You can find it in our guide for setting up Ubuntu and Debian, and it's really simple to follow!</div><br/>
|
||||
|
||||
|
||||
<div className="head">Step 1 — Getting the Latest Updates</div>
|
||||
|
||||
<div className="text">Before adding any new programs, let's make sure your system is all caught up. To do that, type:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get update`} /><br/>
|
||||
|
||||
<div className="text">This command checks if there are any newer versions of the software on your computer. It's like looking for updates to make sure you have the latest and greatest stuff from the place where your computer gets its software.</div><br/>
|
||||
|
||||
<div className="text">If your server is important for work or projects, be careful when updating. Check each update to make sure it's really needed for your computer. In our example, we installed everything just for this tutorial.Once you're sure the updates are necessary, go ahead and update your server using the command below:</div><br/>
|
||||
|
||||
<div className="text">If you decide the updates are important for your computer, go ahead and update your server. Just type in the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get dist-upgrade`} /><br/>
|
||||
|
||||
<div className="text">This process might take a bit, depending on your computer's setup and internet speed. If it's a new server, it should be quick, just a few seconds.<br/><br/>
|
||||
Now your computer is all updated and ready for the next step – installing the Apache web server to handle your internet connections. Let's get started!</div>
|
||||
|
||||
<div className="head">Step 2 — Putting Apache and updating the firewall in place</div>
|
||||
|
||||
<div className="text">Now, let's move on to the next step of setting up our LAMP stack: installing the Apache web server. Apache is a popular and trusted web server that helps your computer show web pages. To install Apache, just type this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install apache2 apache2-doc`} /><br/>
|
||||
<div className="text">This will install the basic Apache web server along with its documentation. It might take a little bit as it sets everything up. Once it's finished, apt-get will let you know, and that's it!</div><br/>
|
||||
|
||||
<div className="text">Now, if you've set up a firewall using UFW like we showed you before, you need to make sure it allows traffic for web browsing.</div><br/>
|
||||
|
||||
<div className="text">On Debian 8, UFW comes with pre-made settings for apps, making it easy to adjust your firewall. To see all the app profiles available, just run this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app list`} /><br/>
|
||||
|
||||
<div className="text">These WWW profiles help control the ports used by web servers:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Available applications:
|
||||
. . .
|
||||
WWW
|
||||
WWW Cache
|
||||
WWW Full
|
||||
WWW Secure
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you look at the WWW Full profile, it's like a set of instructions that says it allows traffic to go through on ports 80 and 443:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app info "WWW Full"`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Profile: WWW Full
|
||||
Title: Web Server (HTTP,HTTPS)
|
||||
Description: Web Server (HTTP,HTTPS)
|
||||
|
||||
Ports:
|
||||
80,443/tcp
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Let data come into your computer for web browsing. This profile lets you allow incoming traffic for both regular web (HTTP) and secure web (HTTPS) connections.</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw allow in “WWW Full”`} /><br/>
|
||||
|
||||
<div className="text">Now that we've given permission for internet traffic through our security wall, let's check if our web server is working by making sure it can show a simple web page. First, find the address of your server. To do this, type the following command in the terminal you're using to connect to your server:</div>
|
||||
|
||||
<CodeBlock code={`sudo ifconfig eth0`} /><br/>
|
||||
|
||||
<div className="text">Look at your screen, and you'll see some lines of information. We're interested in finding your server's address, which is like its home on the internet. Look for a number that has four parts separated by dots (like xxx.xxx.xxx.xxx). It usually comes after the words "inet addr:" in the output. That's your server's IP address!</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
inet addr:111.111.111.111
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Remember the number you found (the IP address)? Now, open your web browser, like the one you use to visit websites and type that number into the address bar at the top, just like you do when you visit any other website. Press Enter, and let's see if your server responds!</div>
|
||||
|
||||
<CodeBlock code={`http://111.111.111.111`} /><br/>
|
||||
|
||||
<div className="text">Once you're finished, you'll see the basic Apache 2 web page, like this:</div>
|
||||
|
||||
<img src={debian} alt="Debain" />
|
||||
|
||||
<div className="text">Now that Apache is installed on your server, you can put your website's content in the /var/www/html folder. If you want to make more than one website, you can learn how with virtual hosts in this guide.</div><br/>
|
||||
|
||||
<div className="text">For more help and tips on keeping your Apache server secure, check out Debian’s Apache information.</div><br/>
|
||||
|
||||
<div className="text">With your web server set up, you're ready to create a spot for your website's data. You can do this using MySQL</div><br/>
|
||||
|
||||
|
||||
<div clssName="head">Step 3: Configuring MySQL and securing it</div>
|
||||
|
||||
<div className="text">Now, let's talk about MySQL. This is like a digital filing cabinet for your website. It helps store and organize all the information your site needs to run smoothly. Lots of popular software, like WordPress and Joomla, rely on MySQL to work.</div><br/>
|
||||
|
||||
<div className="text">To get MySQL installed and ready to go with PHP support, just follow these steps:</div><br/>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install mysql-server php5-mysql`} /><br/>
|
||||
|
||||
<div className="text">This will set up MySQL and install everything else it needs. During the installation, you'll be asked to create a new password for the main MySQL user, called "root." Just choose a strong password and remember it!</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <need to add the image> -->
|
||||
|
||||
|
||||
<div className="text">After setting up MySQL, remember that "root" is the special username used for important tasks, like managing your database. Choose a strong password for it, with a mix of letters and numbers.</div><br/>
|
||||
|
||||
<div className="text">Once you've done this, your MySQL installation is complete.</div><br/>
|
||||
|
||||
<div className="text">To make sure your database server stays safe, you'll need to run one more script. Just follow these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">Now, the script will ask you some questions. When it asks, type in the password you set for the root MySQL account. Then, the system will ask you:</div>
|
||||
|
||||
<CodeBlock code={`Interactive
|
||||
Change the root password? [Y/n] n
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Since you've already set the password for the root MySQL account during installation, you can just say "no" when it asks. After that, the script will then ask:</div>
|
||||
|
||||
<CodeBlock code={`Interactive
|
||||
Remove anonymous users? [Y/n] y
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Choose "yes" to remove the anonymous users option for safety.</div><br/>
|
||||
|
||||
<div className="text">Next, you'll be asked whether to allow or disallow remote logins for the root account. For safety reasons, it's best to disallow remote logins for root unless absolutely necessary for your setup</div> <br/>
|
||||
|
||||
<div className="text">Then, you'll be prompted to remove the test database and reload the privilege tables. Respond with "yes" to both of these. This will get rid of the test database and apply the security changes.</div><br/>
|
||||
|
||||
<div className="text">Once everything is done correctly, the script will confirm with:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
All done! If you have completed all of the above steps, your MySQL installation should now be secure.
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Let's make sure our new MySQL server is up and running. Just type in this command:</div>
|
||||
|
||||
<CodeBlock code={`mysql -u root -p`} /><br/>
|
||||
|
||||
<div claasName="text">Now, enter the password you chose for MySQL during the installation process. Remember, this is different from the main root account used for server administration. Once you're in, just type the following to check the server status, version information, and more:</div>
|
||||
|
||||
<CodeBlock code={`status`} /><br/>
|
||||
|
||||
<div className="text">This is a great way to confirm that MySQL is installed and ready for more setup. Once you're done checking the information, simply exit the application by typing:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Once you've made sure that MySQL is up and running, the next thing to do is install PHP. This will allow you to run scripts and handle code on your server</div><br/>
|
||||
|
||||
<div className="head">Step 4: Adding PHP Support</div>
|
||||
|
||||
<div className="text">Now, let's install PHP. PHP stands for PHP: Hypertext Preprocessor. It's a widely used scripting language that's crucial for creating dynamic web content, which many developers rely on.</div><br/>
|
||||
|
||||
<div className="text">To install PHP, just follow these steps:</div><br/>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install php5-common libapache2-mod-php5 php5-cli`} /><br/>
|
||||
|
||||
<div className="text">Once you've agreed to the installation, PHP will be added to your server. You'll notice several packages being installed, not just PHP. No need to worry, though. Your system is simply making sure PHP works smoothly with your Apache2 setup and other programs.</div><br/>
|
||||
|
||||
<div className="text">To apply all the changes from the PHP installation, it's important to restart Apache on your server. Just follow these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo service apache2 restart`} /><br/>
|
||||
|
||||
<div className="text">Now, let’s check if the PHP software is working properly after installation. Go to the folder where your website's files are stored:</div>
|
||||
|
||||
<CodeBlock code={`cd /var/www/html`} /><br/>
|
||||
|
||||
<div className="text">Once you're in the public web directory, open a text editor from your computer. Create a new file named info.php using the following steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano info.php`} /><br/>
|
||||
|
||||
<div className="text">This command will open a simple text editor called nano and create a new blank file with the name "info.php." In this file, you'll type some code to display information about your PHP configuration on a web page. Here's how to do it:</div>
|
||||
|
||||
<CodeBlock code={`<?php phpinfo(); ?>`} /><br/>
|
||||
|
||||
<div className="text">To save your changes and exit the file, press CTRL-X, then press Y to confirm saving, and finally press ENTER to confirm the file name.</div><br/>
|
||||
|
||||
<div className="text">Now, to see the configuration information, open your web browser and type in the following URL, but make sure to replace the highlighted part with your server’s IP address:</div>
|
||||
|
||||
<CodeBlock code={`http://111.111.111.111/info.php`} /><br/>
|
||||
|
||||
<div className="text">If you've followed the steps correctly, you'll see a page displaying basic PHP information, similar to the one below:</div>
|
||||
|
||||
|
||||
<img src={php} alt="php5.9" /><br/>
|
||||
|
||||
<div className="text">When you're finished checking the test PHP page, it's important to remove it for security reasons. To do that, just run this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo rm -i /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">The system will ask if you want to delete the test file you created. Say "yes" to remove it. Once that's done, you've finished installing PHP!</div><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusions:</div>
|
||||
|
||||
<div className="text">Congratulations! You've successfully set up the basic LAMP stack on your server, which means you're ready to start building various websites and web applications. But that's just the beginning! There are plenty of ways to customize and expand your server's capabilities. If you want to learn how to keep your Linux server secure, check out "An Introduction to Securing Your Linux VPS."</div>
|
||||
|
||||
<div className="text">And if you're interested in hosting multiple websites on your server, follow the Apache virtual hosts tutorial.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to take your server to the next level? Let's dive in and explore!</strong></div>
|
||||
425
blog/2019-05-29-blog-16.md
Normal file
@ -0,0 +1,425 @@
|
||||
---
|
||||
slug: Installing and Configuring LAMP Stack on Debian 10 A Comprehensive Tutorial
|
||||
title: Installing and Configuring LAMP Stack on Debian 10 A Comprehensive Tutorial
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import debian from '@site/static/img/debian.png';
|
||||
import todo from '@site/static/img/todo_list.png';
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">A LAMP stack is a group of computer programs that work together to run websites and apps smoothly. LAMP stands for:</div>
|
||||
<div className="text"><ol><li>L for Linux: This is the computer's operating system.</li><li>A for Apache: Apache helps manage the flow of information on the internet.</li><li>M for MariaDB: This is like a big, organized file cabinet where important information for our website is kept.</li><li>P for PHP: PHP takes care of things behind the scenes, making sure everything works smoothly.</li></ol></div>
|
||||
|
||||
<div className="text">Normally, people use MySQL as the file cabinet, but we're using MariaDB because it's like an upgraded version.In this guide, we'll show you how to set up this group of programs on a Debian 10 computer. It's like assembling your own team for a website!</div><br/>
|
||||
|
||||
<div className="head">Requirements</div>
|
||||
|
||||
<div className="text">Before we start, make sure you have a computer running Debian 10. You'll need a special account that lets you do important things (it's called 'sudo-enabled'), and there should be a basic protective barrier called a firewall. If you haven't set up your computer yet, we have a simple guide to help you do that. Once it's ready, you're good to go with the next steps!</div><br/>
|
||||
|
||||
<div className="head">Step 1 — Set up Apache and update the firewall</div>
|
||||
<div className="text">Let's begin by installing Apache, a popular web server. It's like a traffic director for your website, making sure everything goes smoothly.</div><br/>
|
||||
|
||||
<div className="text">To start, we'll make sure our computer knows about the latest stuff available. It's a bit like updating your apps on your phone. If it's the first time you're doing something important, the computer might ask for your password just to make sure it's really you making the decisions. Once that's done, we're ready for the next steps!</div>
|
||||
|
||||
<CodeBlock code={`sudo apt update`} /><br/>
|
||||
|
||||
<div className="text">Now, let's install Apache. Just follow these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install apache2`} /><br/>
|
||||
|
||||
<div className="text">After installing Apache, you might be asked to confirm by pressing 'Y' and then hitting 'ENTER'. Once that's done, let's make sure your computer's firewall is set up right.</div><br/>
|
||||
|
||||
<div className="text">If you used the UFW firewall following our guide, we'll check a few things. Think of UFW like a protector for your computer. We want it to allow good website traffic.</div><br/>
|
||||
|
||||
<div className="text">To do that, look at a list of rules it already knows. Follow these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app list`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Available applications:
|
||||
. . .
|
||||
WWW
|
||||
WWW Cache
|
||||
WWW Full
|
||||
WWW Secure
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">"If you check the WWW Full profile, it's like looking at your website's settings. It allows traffic on the important ports, like port 80 and 443:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app info "WWW Full"`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Profile: WWW Full
|
||||
Title: Web Server (HTTP,HTTPS)
|
||||
Description: Web Server (HTTP,HTTPS)
|
||||
Ports:
|
||||
80,443/tcp
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Let's make sure your website can accept visitors. Allow incoming traffic for your website by following these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw allow in "WWW Full"`} /><br/>
|
||||
|
||||
<div className="text">To check if everything worked, open your web browser and visit your server's public address. It's like looking at your website to make sure it's up and running.</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_ip`} /><br/>
|
||||
|
||||
<div className="text">You'll see a page that says 'Apache2 Debian Default Page.' This page is just for testing and giving you information:</div><br/>
|
||||
|
||||
<img src={debian} alt="Debain" /> <br/>
|
||||
|
||||
<div className="text">If you see a page that says 'Apache2 Debian Default Page,' then your website is set up correctly, and people can visit it through the internet.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>The best way to find your server's IP address</div>
|
||||
|
||||
<div className="text">Finding your server's public IP address is like figuring out its location on the internet. This is the address you use to connect to your server. <br/> <br/> Here's a simple way to find it:" <br/> <br/> If you don't know your server's public address, it's like not knowing the address of your friend's house. But don't worry, there are easy ways to find it. One way is to use the following command:</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">When you run the command, you'll see two or three lines. All of them are correct addresses, but your computer might use only one. You can try each one to see which works.</div><br/>
|
||||
|
||||
<div className="text">Another way is to use a tool called curl to check your server's address. It's like using a special tool to find out the address.</div><br/>
|
||||
|
||||
<div className="text">Since Debian 10 doesn't have curl installed by default, you'll need to add it first:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install curl`} /><br/>
|
||||
|
||||
<div className="text">After that, use this command to ask a specific server what your IP address is:</div>
|
||||
|
||||
<CodeBlock code={`curl http://icanhazip.com`} /><br/>
|
||||
|
||||
<div className="text">No matter which way you found your IP address, type it into your web browser to make sure your server is showing the default Apache page.</div><br/>
|
||||
|
||||
<div className="head">Step 2 — Setting up MariaDB</div>
|
||||
<div className="text">Now that your website has a web server running, it's time to set up a storage space for all its data. This is like installing a big filing cabinet for your website.</div><br/>
|
||||
|
||||
<div className="text">In Debian 10, we use something called 'default-mysql-server' to set up this filing cabinet. It's like a special piece of furniture that helps organize and manage all the information your website needs. This 'default-mysql-server' actually points to MariaDB, a type of database system that works a lot like the original MySQL. Let's get this filing cabinet installed!</div><br/>
|
||||
|
||||
<div className="text">For better compatibility in the long run, it's suggested to install MariaDB using a specific program called 'mariadb-server' instead of a general one.</div><br/>
|
||||
|
||||
<div className="text">To do this, just run the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install mariadb-server`} /><br/>
|
||||
|
||||
<div className="text">After the installation is done, it's a good idea to run a special security script that comes with MariaDB. This script helps make sure everything is safe and secure by fixing some default settings and restricting access to your database system.To run this helpful script, just enter the following command:</div><br/>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">This script will ask you a few questions to make sure your MariaDB is set up securely. The first question is about the 'database root password.' It's not the same as the computer's main password. Think of it as a special key for your database. Since you just installed MariaDB and haven't set up any passwords yet, just press 'ENTER' when it asks for the password.</div><br/>
|
||||
|
||||
<div className="text">The next question is about setting up a special password for the 'database root.' However, MariaDB has a safer way to handle this, so you don't have to set a password right now. Just type 'N' and then press 'ENTER'.</div><br/>
|
||||
|
||||
<div className="text">After that, you can just press 'Y' and then 'ENTER' to accept the default options for the rest of the questions. This will remove some unnecessary settings, make sure remote login is disabled, and apply the changes immediately.
|
||||
Once that's done, you can log in to the MariaDB console."</div>
|
||||
|
||||
<CodeBlock code={`sudo mariadb`} /><br/>
|
||||
|
||||
<div className="text">This will connect you to the MariaDB server as the main database user called 'root.' This happens because of the way we're running the command. You should see the following message:</div><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
||||
Your MariaDB connection id is 42
|
||||
Server version: 10.3.36-MariaDB-0+deb10u2 Debian 10
|
||||
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
|
||||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
||||
MariaDB [(none)]>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">You probably noticed that you didn't have to type a password to log in as the main database user ('root'). This happens because of a special way the database checks who you are. This might seem strange, but it actually makes things more secure. Only people with special access (like you, using the console or certain applications) can log in as the main 'root' user. So, if you're using a regular program or your website, you won't use this main 'root' user. It's like having different keys for different doors, and your website has its own key.</div><br/>
|
||||
|
||||
<div className="text">For better security, it's a good idea to create special user accounts for each database, especially if you're going to have more than one on your server.</div><br/>
|
||||
|
||||
<div className="text">If you want to leave the MariaDB console, just follow these steps:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Your MariaDB server is now installed and safe. Next up, you'll install PHP, which is the last part of the LAMP stack.</div><br/>
|
||||
|
||||
<div className="head">Step 3 — Adding PHP to the server</div>
|
||||
<div className="text">You've got Apache serving your website, and MariaDB handling all your data. Now, let's introduce PHP - it makes your site do cool things. It can run special scripts, talk to your MariaDB database for info, and then show the final result on your website.</div><br/>
|
||||
|
||||
<div className="text">Along with the main PHP package, we need two more things to make everything work smoothly. One is called 'php-mysql,' which helps PHP talk to the database. The other is 'libapache2-mod-php,' which makes sure Apache can handle PHP files properly. Don't worry, the necessary basic PHP stuff will be installed automatically.</div><br/>
|
||||
|
||||
<div className="text">To get all these, just run this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install php libapache2-mod-php php-mysql`} /><br/>
|
||||
|
||||
<div className="text">After everything is installed, you can check which version of PHP you have by using this command:</div>
|
||||
|
||||
<CodeBlock code={`php -v`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
PHP 7.3.31-1~deb10u2 (cli) (built: Dec 15 2022 09:39:10) ( NTS )
|
||||
Copyright (c) 1997-2018 The PHP Group
|
||||
Zend Engine v3.3.31, Copyright (c) 1998-2018 Zend Technologies
|
||||
with Zend OPcache v7.3.31-1~deb10u2, Copyright (c) 1999-2018, by Zend Technologies
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Usually, when someone asks for a folder on your website, Apache looks for a file called index.html. To make it look for PHP files first, we need to tweak a setting.</div><br/>
|
||||
|
||||
<div className="text">Just follow these steps: Run the following command to open a file called dir.conf. We'll use a simple text editor called nano for this</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/mods-enabled/dir.conf`} /><br/>
|
||||
|
||||
<div className="text">Inside the file, you'll see something like this:</div>
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c>
|
||||
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After you've made your changes, save and close the file. If you're using nano, just press CTRL+X, then Y, and finally, press ENTER to confirm.</div><br/>
|
||||
|
||||
<div className="text">Now, let's make sure Apache knows about the changes. To do that, follow these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl reload apache2`} /><br/>
|
||||
|
||||
<div className="text">To see how Apache is doing, you can use this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl status apache2`} /><br/>
|
||||
|
||||
<CodeBlock code={`Sample Output
|
||||
● apache2.service - The Apache HTTP Server
|
||||
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset:
|
||||
Active: active (running) since Fri 2023-01-20 22:21:24 UTC; 2min 12s ago
|
||||
Docs: https://httpd.apache.org/docs/2.4/
|
||||
Process: 13076 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCC
|
||||
Process: 13097 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/
|
||||
Main PID: 13080 (apache2)
|
||||
Tasks: 6 (limit: 4915)
|
||||
Memory: 13.7M
|
||||
CGroup: /system.slice/apache2.service
|
||||
├─13080 /usr/sbin/apache2 -k start
|
||||
├─13101 /usr/sbin/apache2 -k start
|
||||
├─13102 /usr/sbin/apache2 -k start
|
||||
├─13103 /usr/sbin/apache2 -k start
|
||||
├─13104 /usr/sbin/apache2 -k start
|
||||
└─13105 /usr/sbin/apache2 -k start
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, your LAMP stack is ready to go, but before you try out a PHP script, let's organize your website's files and folders properly. We'll do this by setting up something called an 'Apache Virtual Host.' It's like creating a dedicated space for your website, and we'll do that in the next step.</div><br/>
|
||||
|
||||
<div className="head">Step 4 — Creating a Virtual Host for your Website</div>
|
||||
|
||||
<div className="text">Alright, so with the Apache web server, you can create something called a 'Virtual Host.' Think of it like having different rooms for different websites on the same server. In this step, we'll set up a 'room' for your website, and we'll call it a 'Virtual Host.' We'll use a pretend domain name called 'your_domain,' but you'll replace this with your actual domain name.</div><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: If you're using Cloudtopiaa for your website's address (DNS), you can find detailed instructions in our guides on how to set up a new domain name and link it to your server. It's like telling the internet where to find your website.</div><br/>
|
||||
|
||||
<div className="text">By default, Apache puts its website stuff in a folder at /var/www/html and follows the rules in a file at /etc/apache2/sites-available/000-default.conf. Instead of changing these default settings, let's make a special setup just for testing your PHP setup. We're going to create a new 'Virtual Host,' which allows Apache to handle multiple websites on the same server. We'll also organize the files for your pretend website in a special folder inside /var/www, leaving the default stuff at /var/www/html for now. It's like having different places for different websites, and we're creating one for your practice site.</div><br/>
|
||||
|
||||
<div className="text">Start by making the main folder for your website, 'your_domain,' like this:</div>
|
||||
|
||||
<CodeBlock code={`sudo mkdir /var/www/your_domain`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make sure your website folder is owned by you. You can do this by running the following command, which uses a special code ($USER) to refer to your user account:</div>
|
||||
|
||||
<CodeBlock code={`sudo chown -R $USER:$USER /var/www/your_domain`} /><br/>
|
||||
|
||||
<div className="text">After that, let's open a new settings file for your website in a special place called 'sites-available' in Apache. We'll use a simple text editor called nano for this. Here's how:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/sites-available/your_domain.conf`} /><br/>
|
||||
|
||||
<div className="text">Now that you have a new file, let's add some basic settings to it. Copy and paste the following simple configuration, but don't forget to replace 'your_domain' with your actual domain name:</div>
|
||||
|
||||
<CodeBlock code={`<VirtualHost *:80>
|
||||
ServerName your_domain
|
||||
ServerAlias www.your_domain
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/your_domain
|
||||
ErrorLog $ {APACHE_LOG_DIR}/error.log
|
||||
CustomLog $ {APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">With this configuration, Apache will use the folder '/var/www/your_domain' to show your website when someone visits 'your_domain'.If you're just testing Apache without a real domain name, you can skip this step. Just put a '#' in front of 'ServerName' and 'ServerAlias' lines to ignore them.</div><br/>
|
||||
|
||||
<div className="text">Once you're finished, save and close the file.</div><br/>
|
||||
|
||||
<div className="text">Now, let's tell Apache to start using this setup by running this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2ensite your_domain`} /><br/>
|
||||
|
||||
<div className="text">If you're not using a custom domain name and want to make sure your new setup works, it's a good idea to turn off the default website that comes with Apache. This step is necessary to avoid any conflicts with your own setup. To do this, just run the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2dissite 000-default`} /><br/>
|
||||
|
||||
<div className="text">To check if you didn't make any mistakes in your configuration file, run the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apache2ctl configtest`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make sure Apache knows about the changes you made. To do that, run the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl reload apache2`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a simple PHP script to check if PHP is working correctly on your server.</div><br/>
|
||||
|
||||
<div className="head">Step 5 — Verifying PHP processing on your server</div>
|
||||
|
||||
<div className="text">Now that you've set up a location for your website, let's check if everything is working by creating a simple PHP test script.<br/><br/>
|
||||
First, make a new file called 'info.php' in your website's folder:</div>
|
||||
|
||||
<CodeBlock code={`nano /var/www/your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">This will open a new empty file. Copy and paste the following text into the file. Don't worry, it's just some code that PHP understands:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
phpinfo();
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After you've pasted the code, save and close the file.<br/><br/>
|
||||
Now, let's check if everything is working. Open your web browser and type in your server's address or IP, followed by the script name 'info.php':</div>
|
||||
|
||||
<CodeBlock code={`http://your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">Here's an example of what the basic PHP web page looks like:</div>
|
||||
|
||||
<!-- <need add a image> -->
|
||||
|
||||
<div className="text">This page shows some basic details about your server from the PHP perspective. It's handy for checking if everything is set up correctly.</div><br/>
|
||||
|
||||
<div className="text">If you see this page in your browser, it means your PHP installation is good to go.<br/><br/>
|
||||
After checking the info, it's a good idea to delete the file you created because it has sensitive information about your PHP setup and your Debian server. You can do this by running the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo rm /var/www/your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">If you ever need to see this information again, you can always make this page once more. It's like creating a note that you can take out whenever you want.</div>
|
||||
|
||||
<div className="head">Step 6 — Connecting to the database from PHP (optional)</div>
|
||||
|
||||
<div className="text">If you want to check if PHP can talk to MariaDB (the database) and do some cool stuff, you can create a test table with data and ask PHP to fetch it. But before we do that, let's set up a database and a special user for it.</div><br/>
|
||||
|
||||
<div className="text">To start, let's connect to the MariaDB console using the main 'root' account:</div>
|
||||
|
||||
<CodeBlock code={`sudo mariadb`} /><br/>
|
||||
|
||||
<div className="text">To make a new space for our data, run this command in the MariaDB console:</div>
|
||||
|
||||
<CodeBlock code={`CREATE DATABASE example_database;`} /><br/>
|
||||
|
||||
<div className="text">Next, let's make a new user and give them full control over the database you just made.<br/><br/>
|
||||
Use this command to create a new user called 'example_user' who logs in with a password. We're setting the password as 'password' for this example, but you should use a strong password of your own:</div>
|
||||
|
||||
<CodeBlock code={`CREATE USER 'example_user'@'%' IDENTIFIED BY 'password';`} /><br/>
|
||||
|
||||
<div className="text">Now, let's give our new user control over the 'example_database' we created. Use this command:</div>
|
||||
|
||||
<CodeBlock code={`GRANT ALL ON example_database.* TO 'example_user'@'%';`} /><br/>
|
||||
|
||||
<div className="text">This makes sure our user 'example_user' can do anything they want with the 'example_database,' but they can't mess with any other databases on your server.</div><br/>
|
||||
|
||||
<div className="text">Now, let's save these changes so they take effect right away. Run this command:</div>
|
||||
|
||||
<CodeBlock code={`FLUSH PRIVILEGES;`} /><br/>
|
||||
|
||||
<div className="text">Now, let's get out of the MariaDB shell. You can do this by running the following command:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">To check if our new user has the right powers, let's log in to the MariaDB shell again. But this time, we'll use the special credentials we just made for our custom user:</div>
|
||||
|
||||
<CodeBlock code={`mariadb -u example_user -p`} /><br/>
|
||||
|
||||
<div className="text">Remember to use the -p flag in this command; it will ask you for the password you set when making the 'example_user.' After you've logged in, check that you can access the 'example_database':</div>
|
||||
|
||||
<CodeBlock code={`SHOW DATABASES;`} /><br/>
|
||||
|
||||
<div className="text">You should see something like this as the output:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+--------------------+
|
||||
| Database |
|
||||
+--------------------+
|
||||
| example_database |
|
||||
| information_schema |
|
||||
+--------------------+
|
||||
2 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a pretend table named 'todo_list.' In the MariaDB console, type in this command:</div>
|
||||
|
||||
<CodeBlock code={`CREATE TABLE example_database.todo_list (
|
||||
item_id INT AUTO_INCREMENT,
|
||||
content VARCHAR(255),
|
||||
PRIMARY KEY(item_id)
|
||||
);
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Let's add some pretend data to our table. In the MariaDB console, run this command a few times, changing the values each time to fill up our test table:</div>
|
||||
|
||||
<CodeBlock code={`INSERT INTO example_database.todo_list (content) VALUES ("My first important item");`} /><br/>
|
||||
|
||||
<div className="text">To make sure everything got saved in your table, run this command:</div>
|
||||
|
||||
<CodeBlock code={`SELECT * FROM example_database.todo_list;`} /><br/>
|
||||
|
||||
<div className="text">You should see something like this as the output:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+---------+--------------------------+
|
||||
| item_id | content |
|
||||
+---------+--------------------------+
|
||||
| 1 | My first important item |
|
||||
| 2 | My second important item |
|
||||
| 3 | My third important item |
|
||||
| 4 | and this one more thing |
|
||||
+---------+--------------------------+
|
||||
4 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you've checked and everything looks good in your test table, you can leave the MariaDB console. Just run the following command:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a PHP file that talks to MariaDB and gets your data. Create a new file in your website folder using a text editor. We'll use nano in this example:</div><br/>
|
||||
|
||||
<CodeBlock code={`nano /var/www/your_domain/todo_list.php`} /><br/>
|
||||
|
||||
<div className="text">The PHP script below talks to the MariaDB database and asks for the stuff in the 'todo_list' table. It then shows the results as a list. If there's any issue connecting to the database, it will give an error.</div><br/>
|
||||
|
||||
<div className="text">Copy and paste this code into your 'todo_list.php' file. Just make sure to replace 'example_user' and 'password' with your own values:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
$user = "example_user";
|
||||
$password = "password";
|
||||
$database = "example_database";
|
||||
$table = "todo_list";
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
|
||||
echo "<h2>TODO</h2><ol>";
|
||||
foreach($db->query("SELECT content FROM $table") as $row) {
|
||||
echo "<li>" . $row['content'] . "</li>";
|
||||
}
|
||||
echo "</ol>";
|
||||
} catch (PDOException $e) {
|
||||
print "Error!: " . $e->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've finished making changes, save and close the file.</div><br/>
|
||||
|
||||
<div className="text">Now, you can view this page in your web browser by going to your website's domain name or public IP address, followed by '/todo_list.php':</div>
|
||||
|
||||
<CodeBlock code={`http://your_domain/todo_list.php`} /><br/>
|
||||
|
||||
<div className="text">This webpage will show the things you added to your pretend list to anyone who visits it:</div><br/>
|
||||
|
||||
<img src={todo} alt="Todo-List" /> <br/>
|
||||
|
||||
<div className="text">This tells you that your PHP setup is good to go and can talk to your MariaDB server.</div><br/>
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
<div className="text">Great job! Now you've set up a strong foundation for showing PHP websites and apps to your visitors, using Apache for the web server and MariaDB as the database.</div>
|
||||
|
||||
<div className="text">Next, let's make sure your website is secure by using HTTPS. To do this, you can use Let’s Encrypt. If you're interested in managing dependencies and packages for your PHP projects, check out our guide on How to Install and Use Composer.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to make your website even better? Follow our guides for more steps and improvements!</strong></div>
|
||||
288
blog/2019-05-29-blog-17.md
Normal file
@ -0,0 +1,288 @@
|
||||
---
|
||||
slug: Getting Started with Ansible Installing and Configuring LAMP on Ubuntu 18.04
|
||||
title: Getting Started with Ansible Installing and Configuring LAMP on Ubuntu 18.04
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import php from '@site/static/img/phpinfo.png';
|
||||
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div classNam="text">Automating server setup is crucial in today's world, where applications often come and go. Tools like Ansible make this process easier by creating standard procedures for new servers and reducing mistakes that can happen with manual setups.</div><br/>
|
||||
|
||||
<div className="text">Ansible is great because it has a simple design and doesn't need extra software on your servers. It also comes with lots of useful features and built-in tools that make writing automation scripts easier.</div><br/>
|
||||
|
||||
<div className="text">This guide will show you how to use Ansible to automate the steps from our tutorial on setting up a LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 18.04. A LAMP stack is like a bundle of tools that work together to let a server host dynamic websites and web apps. 'LAMP' stands for Linux (the operating system), Apache (the web server), MySQL (where site data is stored), and PHP (for processing dynamic content).</div><br/>
|
||||
|
||||
<div className="head">What You Need Before Automating Server Setup with Ansible</div>
|
||||
|
||||
<div className="text">Before you can use the playbook to automate the setup, make sure you have:</div><br/>
|
||||
|
||||
<div className="text">One main Ansible control node: This is an Ubuntu 18.04 machine with Ansible installed. It should be configured to connect to your other servers using SSH keys. Also, make sure this machine has a regular user with sudo permissions and has a firewall enabled. You can set up Ansible by following our guide on 'How to Install and Configure Ansible on Ubuntu 18.04'. One or more Ansible Hosts: These are remote Ubuntu 18.04 servers that you've already set up using Ansible. You can do this by following our guide on 'How to Use Ansible to Automate Initial Server Setup on Ubuntu 18.04'.</div><br/>
|
||||
|
||||
<div className="text">Before we dive in, let's make sure your Ansible control node can talk to and command your Ansible host(s). For a quick check, take a look at step 3 in our guide on 'How to Install and Configure Ansible on Ubuntu 18.04'.</div><br/>
|
||||
|
||||
<div className="head">Automating LAMP Setup: A Quick Guide with Ansible Playbook</div>
|
||||
|
||||
<div className="text">This Ansible playbook is like a shortcut compared to doing things step by step from our guide on 'How To Install Linux, Apache, MySQL and PHP (LAMP) on Ubuntu 18.04'.</div>
|
||||
|
||||
<div className="text">When you run this playbook, it will do the following on your Ansible hosts:</div>
|
||||
|
||||
<div className="text"><ol><li>Install aptitude, a tool Ansible likes to use instead of the regular apt package manager.</li><li>Install all the necessary packages for LAMP.</li><li>Create a special place for your website and set it up with Apache.</li><li>Turn on this new place for your website.</li><li>Turn off the default Apache website if you want to (you can decide).</li><li>Set a password for the big boss of your MySQL database.</li><li>Clean up some unnecessary things in MySQL.</li><li>Make sure your firewall allows traffic for your website on the internet highway</li><li>Add a little PHP script to test if everything's working.</li></ol></div>
|
||||
|
||||
<div className="text">After the playbook completes, you'll have a working web environment that runs PHP on Apache. It'll be set up just the way you wanted, thanks to the choices you made in the configuration.</div>
|
||||
|
||||
<div className="head">Fetching the LAMP Playbook and Dependencies</div>
|
||||
|
||||
<div className="text">Now, let's get our hands on the LAMP playbook and the things it needs from the do-community/ansible-playbooks place. We're going to copy this stuff to a special spot on the computer that controls Ansible.</div><br/>
|
||||
|
||||
<div className="text">If you've done this copying before when following another guide, find the folder where you saved these playbooks and run a command that looks like 'git pull' to make sure everything is up-to-date.</div>
|
||||
|
||||
<CodeBlock code={`cd ~/ansible-playbooks
|
||||
git pull
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you've never done this before, let's start by making a copy of the do-community/ansible-playbooks stuff and putting it in a special place. Use the command below to do this:</div>
|
||||
|
||||
<CodeBlock code={`cd ~
|
||||
git clone https://github.com/do-community/ansible-playbooks.git
|
||||
cd ansible-playbooks
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The things we want are kept in a folder called lamp_ubuntu1804. Inside, you'll find these files organized like this:</div>
|
||||
|
||||
<CodeBlock code={`lamp_ubuntu1804
|
||||
├── files
|
||||
│ ├── apache.conf.j2
|
||||
│ └── info.php.j2
|
||||
├── vars
|
||||
│ └── default.yml
|
||||
├── playbook.yml
|
||||
└── readme.md
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Let's take a quick look at what each of these files does:</div>
|
||||
|
||||
<div className="text"><ol><li>files/info.php.j2: This file is like a blueprint for creating a PHP test page on the web server's main spot.</li><li>files/apache.conf.j2: Think of this file as a plan for setting up the Apache VirtualHost.</li><li>vars/default.yml: Here, you can tweak settings in the playbook to match what you want.</li><li>playbook.yml: The real action happens in this file. It has a list of things to do on the remote server(s).</li><li>readme.md: This is just a text file with info about how to use this playbook.</li></ol></div>
|
||||
|
||||
<div className="text">Let's make some changes to how our playbook works. Go to the lamp_ubuntu1804 folder, find a file named vars, and open up a file called default.yml. You can use any text editor you like for this, just pick your favorite one!</div>
|
||||
|
||||
<CodeBlock code={`cd lamp_ubuntu1804
|
||||
nano vars/default.yml
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">This file has some things you might want to change:</div>
|
||||
|
||||
<CodeBlock code={`---
|
||||
mysql_root_password: "mysql_root_password"
|
||||
app_user: "sammy"
|
||||
http_host: "your_domain"
|
||||
http_conf: "your_domain.conf"
|
||||
http_port: "80"
|
||||
disable_default: true
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Here are some things you might want to change in this file:</div>
|
||||
|
||||
<div className="text"><ol><li>mysql_root_password: Choose a password for the main MySQL account.</li><li>app_user: Pick a non-root user on your server who will own the application files.</li><li>http_host: Your domain name.</li><li>http_conf: The name of the configuration file in Apache.</li><li>http_port: The HTTP port for your website (usually 80).</li><li>disable_default: Decide whether to turn off the default Apache website.</li></ol></div>
|
||||
|
||||
<div className="text">After updating the variables, save and close the file. If you used nano, press CTRL + X, Y, then ENTER.</div><br/>
|
||||
|
||||
<div className="text">Now, it's time to run the playbook on your server. Playbooks usually run on every server in your inventory, but we can target a specific server using the -l flag. Also, we can specify the user with the -u flag.</div><br/>
|
||||
|
||||
<div className="text">To run the playbook on 'server1' as 'sammy', use this command:</div>
|
||||
|
||||
<CodeBlock code={`ansible-playbook playbook.yml -l server1 -u sammy`} /><br/>
|
||||
|
||||
<div className="text">After running the playbook, you'll see output similar to this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
PLAY [all] *********************************************************************************************************
|
||||
TASK [Gathering Facts] *********************************************************************************************************ok: [server1]
|
||||
|
||||
TASK [Install prerequisites] *********************************************************************************************************ok: [server1] => (item=aptitude)
|
||||
|
||||
...
|
||||
|
||||
TASK [UFW - Allow HTTP on port 80] *********************************************************************************************************
|
||||
changed: [server1]
|
||||
|
||||
TASK [Sets Up PHP Info Page] *********************************************************************************************************
|
||||
changed: [server1]
|
||||
|
||||
RUNNING HANDLER [Reload Apache] *********************************************************************************************************
|
||||
changed: [server1]
|
||||
|
||||
RUNNING HANDLER [Restart Apache] *********************************************************************************************************
|
||||
changed: [server1]
|
||||
|
||||
PLAY RECAP *********************************************************************************************************
|
||||
server1 : ok=15 changed=11 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once the playbook completes its tasks, open your web browser and enter the hostname or IP address of your server, as specified in the playbook variables, followed by "/info.php:</div>
|
||||
|
||||
<CodeBlock code={`http://server_host_or_IP/info.php`} /><br/>
|
||||
|
||||
<div className="text">You'll encounter a page similar to this:</div>
|
||||
|
||||
<img src={php} alt="PHP Info" /> <br/>
|
||||
|
||||
<div className="text">To enhance security, it's advisable to delete this page from the server after setup. You can do this by using the command rm -f /var/www/info.php once the setup is complete.</div><br/>
|
||||
|
||||
<div className="head">Accessing the LAMP Server Setup Script</div>
|
||||
<div className="text">The LAMP server setup script discussed in this guide is located in the lamp_ubuntu1804 folder within the Cloudtopiaa Community Playbooks repository. To access or download the script contents directly, click the "Raw" button at the top of each script.</div><br/>
|
||||
|
||||
<div className="text">For your convenience, the complete contents of the playbook, along with its associated files, are also provided below.</div>
|
||||
|
||||
<CodeBlock code={`vars/default.yml`} /><br/>
|
||||
|
||||
<div className="text">The "default.yml" file has important information that a playbook uses for its tasks. For example, it might include the password for the main MySQL account and the name of the website for Apache to set up. So, if you need to adjust these details, you'd do it in this file.</div>
|
||||
|
||||
<CodeBlock code={`---
|
||||
mysql_root_password: "mysql_root_password"
|
||||
app_user: "sammy"
|
||||
http_host: "your_domain"
|
||||
http_conf: "your_domain.conf"
|
||||
http_port: "80"
|
||||
disable_default: true
|
||||
`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>files/apache.conf.j2</div>
|
||||
|
||||
<div className="text">The "apache.conf.j2" file is like a blueprint for setting up a special space on your Apache web server. It uses a file called "default.yml" to know specific details, like what the new space should be called and other important settings. So, when you want to change how your website works, you can do it by adjusting things in the "default.yml" file.</div>
|
||||
|
||||
<CodeBlock code={`<VirtualHost *:{{ http_port }}>
|
||||
ServerAdmin webmaster@localhost
|
||||
ServerName {{ http_host }}
|
||||
ServerAlias www.{{ http_host }}
|
||||
DocumentRoot /var/www/{{ http_host }}
|
||||
ErrorLog $ {APACHE_LOG_DIR}/error.log
|
||||
CustomLog $ {APACHE_LOG_DIR}/access.log combined
|
||||
|
||||
<Directory /var/www/{{ http_host }}>
|
||||
Options -Indexes
|
||||
</Directory>
|
||||
|
||||
<IfModule mod_dir.c>
|
||||
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
|
||||
</IfModule>
|
||||
|
||||
</VirtualHost>
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>files/info.php.j2</div>
|
||||
|
||||
<div className="text">The "info.php.j2" file is like a special script that helps test your new LAMP server (Linux, Apache, MySQL, PHP). It sets up a simple PHP test in the main location of your server, so you can make sure everything is working as it should. If you want to check if your server is running properly, this file helps you do that.</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
phpinfo();
|
||||
`} /><br/>
|
||||
|
||||
<div className="head">Understanding the playbook.yml File in Simple Terms</div>
|
||||
|
||||
<div className="text">The "playbook.yml" file is like the main plan that tells your computer what to do. In this plan, it first says which group of servers it's going to work on (probably all of them). Then, it mentions that it's going to do some important tasks with extra powers (like using sudo). After that, it grabs settings and options from another file called "default.yml" to know exactly what to do and how to set things up. So, it's a guide for your computer on getting everything ready.</div>
|
||||
|
||||
<CodeBlock code={`---
|
||||
- hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/default.yml
|
||||
|
||||
tasks:
|
||||
- name: Install prerequisites
|
||||
apt: name={{ item }} update_cache=yes state=latest force_apt_get=yes
|
||||
loop: [ 'aptitude' ]
|
||||
|
||||
#Apache Configuration
|
||||
- name: Install LAMP Packages
|
||||
apt: name={{ item }} update_cache=yes state=latest
|
||||
loop: [ 'apache2', 'mysql-server', 'python3-pymysql', 'php', 'php-mysql', 'libapache2-mod-php' ]
|
||||
|
||||
- name: Create document root
|
||||
file:
|
||||
path: "/var/www/{{ http_host }}"
|
||||
state: directory
|
||||
owner: "{{ app_user }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: Set up Apache virtualhost
|
||||
template:
|
||||
src: "files/apache.conf.j2"
|
||||
dest: "/etc/apache2/sites-available/{{ http_conf }}"
|
||||
notify: Reload Apache
|
||||
|
||||
- name: Enable new site
|
||||
shell: /usr/sbin/a2ensite {{ http_conf }}
|
||||
notify: Reload Apache
|
||||
|
||||
- name: Disable default Apache site
|
||||
shell: /usr/sbin/a2dissite 000-default.conf
|
||||
when: disable_default
|
||||
notify: Reload Apache
|
||||
|
||||
# MySQL Configuration
|
||||
- name: Sets the root password
|
||||
mysql_user:
|
||||
name: root
|
||||
password: "{{ mysql_root_password }}"
|
||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||
|
||||
- name: Removes all anonymous user accounts
|
||||
mysql_user:
|
||||
name: ''
|
||||
host_all: yes
|
||||
state: absent
|
||||
login_user: root
|
||||
login_password: "{{ mysql_root_password }}"
|
||||
|
||||
- name: Removes the MySQL test database
|
||||
mysql_db:
|
||||
name: test
|
||||
state: absent
|
||||
login_user: root
|
||||
login_password: "{{ mysql_root_password }}"
|
||||
|
||||
# UFW Configuration
|
||||
- name: "UFW - Allow HTTP on port {{ http_port }}"
|
||||
ufw:
|
||||
rule: allow
|
||||
port: "{{ http_port }}"
|
||||
proto: tcp
|
||||
|
||||
# PHP Info Page
|
||||
- name: Sets Up PHP Info Page
|
||||
template:
|
||||
src: "files/info.php.j2"
|
||||
dest: "/var/www/{{ http_host }}/info.php"
|
||||
|
||||
handlers:
|
||||
- name: Reload Apache
|
||||
service:
|
||||
name: apache2
|
||||
state: reloaded
|
||||
|
||||
- name: Restart Apache
|
||||
service:
|
||||
name: apache2
|
||||
state: restarted
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Feel free to change these files as you like to make them work better for you. It's like customizing things to fit how you want to do your work.</div><br/>
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">In this guide, we used Ansible to make it easy to set up a special environment on a faraway computer. Since everyone has different preferences for working with databases like MySQL, we suggest looking at the official Ansible guide for more info and cool things you can do with the mysql_user tool.</div>
|
||||
|
||||
<div className="text">If you want to add more cool stuff to how your server works, check out our beginner's guide called "Configuration Management 101: Writing Ansible Playbooks." It will help you do even more awesome things with your computer.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to explore? Dive into the guide and make your server even better!</strong></div>
|
||||
|
||||
|
||||
325
blog/2019-05-29-blog-18.md
Normal file
@ -0,0 +1,325 @@
|
||||
---
|
||||
slug: Building Your Website Foundation Step-by-Step Guide to Installing LAMP Stack on CentOS 8
|
||||
title: Building Your Website Foundation Step-by-Step Guide to Installing LAMP Stack on CentOS 8
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import test from '@site/static/img/test-page.png';
|
||||
import php from '@site/static/img/image-95.jpeg.webp';
|
||||
import todo from '@site/static/img/todo_list.png';
|
||||
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">A "LAMP" stack is like a group of tools that work together to help your computer host websites and web apps made with PHP. Think of it as a team: "L" stands for Linux, the operating system; "A" is for Apache, the web server; "M" is for MariaDB, where all the important data hangs out; and "P" is for PHP, the tool that makes things happen on the website. Together, they create a combination to bring your websites to life!</div><br/>
|
||||
|
||||
<div className="text">In a LAMP stack, which helps your computer host websites, the part that manages data is usually a MySQL database server. However, for CentOS 8, the default toolbox didn't include MySQL. So, people started using MariaDB instead. Think of MariaDB as a friendly cousin of MySQL—it does the same job! The cool thing is, you can switch to MariaDB without needing to change anything in how your website works. It's like swapping out one tool for another without causing any trouble. Easy peasy!</div><br/>
|
||||
|
||||
<div className="text">In this guide, you're going to set up a special toolbox called a LAMP stack on a CentOS 8 server. We'll use MariaDB as the manager for all the important information your website needs. It's like creating a superhero team for your website! Let's get started!</div><br/>
|
||||
|
||||
<div className="head">What You Need Before Setting Up Your Website on CentOS 8</div>
|
||||
|
||||
<div className="text">Before we start, make sure you have a special computer running CentOS 8. You should be logged in as a regular user with some extra powers (sudo privileges), and there's a protective shield on your computer called a firewall. If you haven't set up your computer this way yet, no worries! You can check out our beginner's guide called "Initial Server Setup Guide for CentOS 8" to get everything ready. Once you're set up, we can dive into the fun stuff!</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Step 1: Setting Up the Apache Web Server</div>
|
||||
<div className="text">To show web pages to our visitors, we're going to use Apache, a widely used open-source web server that can be set up to display PHP pages. We'll use dnf, a tool that helps us install software on CentOS 8.</div><br/>
|
||||
|
||||
<div className="text">To install Apache, follow these steps:</div><br/>
|
||||
|
||||
<div className="text">Open the terminal on your CentOS 8 system. (This is like a command center where you can type instructions to your computer.) Type the following command and press Enter:</div>
|
||||
|
||||
<CodeBlock code={`sudo dnf install httpd`} /><br/>
|
||||
|
||||
<div className="text">When asked, type 'y' and press Enter to confirm that you want to install Apache.</div><br/>
|
||||
|
||||
<div className="text">Once the installation is done, use the following command to turn on and start the server:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl start httpd`} /><br/>
|
||||
|
||||
<div className="text">If you've set up the firewalld firewall as we instructed earlier, you'll need to allow connections to Apache. Use the following command to permanently allow HTTP connections, which use port 80 by default:</div>
|
||||
|
||||
<CodeBlock code={`sudo firewall-cmd --permanent --add-service=http`} /><br/>
|
||||
|
||||
<div className="text">To make sure the change worked, you can check by running:</div>
|
||||
|
||||
<CodeBlock code={`sudo firewall-cmd --permanent --list-all`} /><br/>
|
||||
|
||||
<div className="text">You'll get a response that looks something like this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
public
|
||||
target: default
|
||||
icmp-block-inversion: no
|
||||
interfaces:
|
||||
sources:
|
||||
services: cockpit dhcpv6-client http ssh
|
||||
ports:
|
||||
protocols:
|
||||
masquerade: no
|
||||
forward-ports:
|
||||
source-ports:
|
||||
icmp-blocks:
|
||||
rich rules:
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">You'll have to reload the firewall settings so that the changes become active:</div>
|
||||
|
||||
<CodeBlock code={`sudo firewall-cmd --reload`} /><br/>
|
||||
|
||||
<div className="text">Now that you've added the new firewall rule, you can check if the server is working by opening your web browser and typing in your server's public IP address or domain name.</div><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: If you're using Cloudtopiaa as your DNS hosting provider, you can find step-by-step instructions in our product documentation on how to set up a new domain name and connect it to your server.</div><br/>
|
||||
|
||||
<div className="text">If you haven't linked a domain name to your server yet and you're not sure of your server's public IP address, you can find it by running this command:</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">This will show you a few different IP addresses. You can try each of them one by one in your web browser.</div><br/>
|
||||
|
||||
<div className="text">Alternatively, you can check which IP address is reachable from other places on the internet:</div>
|
||||
|
||||
<CodeBlock code={`curl -4 icanhazip.com`} /><br/>
|
||||
|
||||
<div className="text">Copy and paste the IP address that you see into your web browser's address bar, and it will take you to Apache's default landing page.</div><br/>
|
||||
|
||||
<img src={test} alt="Test Page" /> <br/>
|
||||
|
||||
<div className="text">If you can view this page, it means your web server is now installed correctly.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Step 2 — Adding MariaDB to the server</div>
|
||||
<div className="text">Now that your web server is set up, you need to install a database system to store and manage data for your website. We'll install MariaDB, which is similar to MySQL and is commonly used for web applications.</div><br/>
|
||||
|
||||
<div className="text">To install MariaDB, follow these steps,Run the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo dnf install mariadb-server`} /><br/>
|
||||
|
||||
<div className="text">Once the installation is complete, you can turn on and start the MariaDB server by:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl start mariadb`} /><br/>
|
||||
|
||||
<div className="text">To enhance the security of your database server, it's a good idea to run a security script provided with MariaDB. This script helps by removing some insecure default settings and tightening access to your database system. To start the interactive script, simply run:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">This script will guide you through a series of questions where you can adjust your MariaDB setup. The first question will ask for the current database root password. This is different from the system root user. The database root user has complete control over the database system. Since you've just installed MariaDB and haven't set any password yet, simply press ENTER when prompted.</div><br/>
|
||||
|
||||
<div className="text">The next question asks if you want to create a password for the database root user. Since MariaDB uses a more secure authentication method for the root user by default, you don't need to set a password at this time. Simply type 'N' and then press ENTER.</div><br/>
|
||||
|
||||
<div className="text">After that, you can press 'Y' and then ENTER to accept the default options for all the following questions. This will remove anonymous users and the test database, disable remote root login, and apply these new rules immediately so the server will enforce the changes you made.</div><br/>
|
||||
|
||||
<div className="text">Once you're done, log in to the MariaDB console by typing:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo mysql`} /><br/>
|
||||
|
||||
<div className="text">This command connects to the MariaDB server as the main database user called root. The use of "sudo" before the command helps to infer this. When you run this command, you'll likely see something similar to this output:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
||||
Your MariaDB connection id is 9
|
||||
Server version: 10.3.17-MariaDB MariaDB Server
|
||||
|
||||
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
|
||||
|
||||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
||||
|
||||
MariaDB [(none)]>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">You may have noticed that you didn't have to enter a password to log in as the root user. This is because the default way MariaDB handles authentication for the administrative user is through unix_socket instead of using a password. This might seem like a security concern initially, but it actually makes the database server more secure. It ensures that only users with sudo privileges on the system can log in as the MariaDB root user, either directly from the command line or from applications running with similar privileges.In simpler terms, this means you won't be able to use the root user to connect to the database from a PHP application.</div><br/>
|
||||
|
||||
<div className="text">For better security, it's a good practice to have separate user accounts with limited privileges set up for each database, especially if you're hosting multiple databases on your server. To illustrate this setup, we'll create a database called "example_database" and a user named "example_user". Feel free to use different names if you prefer.</div><br/>
|
||||
|
||||
<div className="text">To create a new database, enter the following command in your MariaDB console:</div>
|
||||
|
||||
<CodeBlock code={`CREATE DATABASE example_database;`} /><br/>
|
||||
|
||||
<div className="text">Now you can make a new user and give them complete access to the database you just made. The following command sets the user's password as "password," but you should use a strong password of your own choice:</div>
|
||||
|
||||
<CodeBlock code={`GRANT ALL ON example_database.* TO 'example_user'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;`} /><br/>
|
||||
|
||||
<div className="text">This grants the user "example_user" full control over the "example_database" database, while ensuring they can't create or change other databases on your server.</div><br/>
|
||||
|
||||
<div className="text">After that, you need to flush the privileges to make sure they're saved and ready for use in the current session:</div>
|
||||
|
||||
<CodeBlock code={`FLUSH PRIVILEGES;`} /><br/>
|
||||
|
||||
<div className="text">After completing the previous steps, you can exit the MariaDB shell by typing:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">To check if the new user has the correct permissions, log in to the MariaDB console once more, but this time use the credentials of the custom user:</div>
|
||||
|
||||
<CodeBlock code={`mysql -u example_user -p`} /><br/>
|
||||
|
||||
<div className="text">In this command, notice the "-p" flag, which will ask you to enter the password you selected when creating the "example_user" user. Once you're logged in to the MariaDB console, check to see if you can access the "example_database" database:</div>
|
||||
|
||||
<CodeBlock code={`SHOW DATABASES;`} /><br/>
|
||||
|
||||
<div className="text">You'll see something like this displayed:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+--------------------+
|
||||
| Database |
|
||||
+--------------------+
|
||||
| example_database |
|
||||
| information_schema |
|
||||
+--------------------+
|
||||
2 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To leave the MariaDB shell, simply type:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now that your database system is set up, you're ready to proceed with installing PHP, which is the last part of setting up the LAMP stack.</div><br/>
|
||||
|
||||
<div className="head">Step 3 — The PHP installation</div>
|
||||
<div className="text">Now that you have Apache set up for serving your website and MariaDB for managing your database, it's time to install PHP. PHP is what processes code to show dynamic content to your website visitors. Along with the main PHP package, we'll need php-mysqlnd, a module that lets PHP communicate with MySQL-based databases. Don't worry, the essential PHP packages will be automatically installed as dependencies.</div><br/>
|
||||
|
||||
<div className="text">To install PHP and php-mysqlnd packages using the dnf package manager, do the following:</div>
|
||||
|
||||
<CodeBlock code={`sudo dnf install php php-mysqlnd`} /><br/>
|
||||
<div className="text">Once the installation is complete, you'll need to restart the Apache web server to activate the PHP module:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl restart httpd`} /><br/>
|
||||
|
||||
<div className="text">Your web server is now ready to go! Next, we'll create a simple PHP testing script to ensure everything is working as it should.</div><br/>
|
||||
|
||||
<div className="head">Step 4 — Using Apache to test PHP</div>
|
||||
<div className="text">When you install Apache on CentOS 8, it automatically sets up a folder called "html" at /var/www/html. You don’t have to adjust any settings in Apache for PHP to function properly on your web server.</div><br/>
|
||||
|
||||
<div className="text">The only change we'll make is to adjust the permission settings on the folder where Apache stores its files. This will allow you to create and edit files in that folder without needing to use "sudo" before each command.</div><br/>
|
||||
|
||||
<div className="text">Use the following command to change the ownership of the default Apache document root to a user and group named "sammy". Make sure to replace "sammy" with your own username and group:</div>
|
||||
|
||||
<CodeBlock code={`sudo chown -R sammy.sammy /var/www/html/`} /><br/>
|
||||
|
||||
<div className="text">sudo chown -R sammy.sammy /var/www/html/</div><br/>
|
||||
|
||||
<div className="text">The default text editor in CentOS 8 is vi, which is powerful but may be challenging for beginners. If you prefer a simpler editor, you can install nano, which is more user-friendly, to help you edit files on your CentOS 8 server.</div>
|
||||
|
||||
<CodeBlock code={`sudo dnf install nano`} /><br/>
|
||||
|
||||
<div className="text">When asked, type 'y' to confirm the installation.<br/><br/>
|
||||
Next, let's create a new PHP file named "info.php" in the /var/www/html directory:</div>
|
||||
|
||||
<CodeBlock code={`nano /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">Below is a simple PHP code that will show details about the PHP environment running on your server:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
|
||||
phpinfo();
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">When you're done, save and close the file. If you're using nano, you can do this by pressing CTRL+X, then Y, and finally hitting ENTER to confirm.</div><br/>
|
||||
|
||||
<div className="text">Now, let's check if our web server can correctly show content generated by a PHP script. Open your web browser and enter your server's hostname or IP address, followed by "/info.php":</div>
|
||||
|
||||
<CodeBlock code={`http://server_host_or_IP/info.php`} /><br/>
|
||||
<div className="text">When you open the browser and visit your server's address followed by "/info.php", you'll see a page that looks something like this:</div><br/>
|
||||
|
||||
<img src={php} alt="Test Page" /> <br/>
|
||||
|
||||
<div className="text">After you've finished checking the PHP server information on that page, it's a good idea to delete the file you created. This is because it contains sensitive details about your PHP environment and CentOS server. You can use the "rm" command to remove the file:</div>
|
||||
|
||||
<CodeBlock code={`rm /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">If you ever need it again in the future, you can always create this file again. Now, let's move on to testing the database connection from the PHP side.</div><br/>
|
||||
|
||||
<div className="head">Step 5 — Connecting to the database from PHP (optional)</div>
|
||||
|
||||
<div className="text">If you'd like to check whether PHP can connect to MariaDB and run database queries, you can create a test table with some sample data and then retrieve this data from a PHP script.</div><br/>
|
||||
|
||||
<div className="text">To begin, let's connect to the MariaDB console using the database user you created earlier in Step 2 of this guide:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`mysql -u example_user -p`} /><br/>
|
||||
|
||||
<div className="text">Let's create a table called "todo_list". In the MariaDB console, enter the following command:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`CREATE TABLE example_database.todo_list (
|
||||
item_id INT AUTO_INCREMENT,
|
||||
content VARCHAR(255),
|
||||
PRIMARY KEY(item_id)
|
||||
);
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's add some data into the "todo_list" table. You can repeat the following command a few times, each time using different values:</div>
|
||||
|
||||
<div className="text">INSERT INTO example_database.todo_list (content) VALUES ("My first important item");</div><br/>
|
||||
|
||||
<div className="text">To make sure the data was saved correctly in your table, execute the following command:</div>
|
||||
|
||||
<CodeBlock code={`SELECT * FROM example_database.todo_list;`} /><br/>
|
||||
|
||||
<div className="text">You'll receive output similar to this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+---------+--------------------------+
|
||||
| item_id | content |
|
||||
+---------+--------------------------+
|
||||
| 1 | My first important item |
|
||||
| 2 | My second important item |
|
||||
| 3 | My third important item |
|
||||
| 4 | and this one more thing |
|
||||
+---------+--------------------------+
|
||||
4 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've confirmed that you have valid data in your test table, you can exit the MariaDB console:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make the PHP script that will connect to MariaDB and retrieve your data. Create a new PHP file in your chosen web directory using your preferred editor. We'll use nano for this:</div><br/>
|
||||
|
||||
<div className="text">nano /var/www/html/todo_list.php</div><br/>
|
||||
|
||||
<div className="text">Copy and paste the following code into your PHP script:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
$user = "example_user";
|
||||
$password = "password";
|
||||
$database = "example_database";
|
||||
$table = "todo_list";
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
|
||||
echo "<h2>TODO</h2><ol>";
|
||||
foreach($db->query("SELECT content FROM $table") as $row) {
|
||||
echo "<li>" . $row['content'] . "</li>";
|
||||
}
|
||||
echo "</ol>";
|
||||
} catch (PDOException $e) {
|
||||
print "Error!: " . $e->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've finished editing, save and close the file.</div><br/>
|
||||
|
||||
<div className="text">Now, you can view this page in your web browser by entering your server's hostname or public IP address, followed by "/todo_list.php":</div>
|
||||
|
||||
<CodeBlock code={`http://server_host_or_IP/todo_list.php`} /><br/>
|
||||
|
||||
<div className="text">You'll see a page similar to this, displaying the content you added to your test table:</div><br/>
|
||||
|
||||
<img src={todo} alt="Todo Page" /> <br/>
|
||||
|
||||
<div className="text">This indicates that your PHP setup is successfully connecting and communicating with your MariaDB server.</div><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
<div className="text">In this guide, you've established a solid base for hosting PHP websites and applications for your visitors. You've configured Apache to handle PHP requests and created a MariaDB database to store your website's data.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to launch your PHP-powered website? Let's get started!</strong></div>
|
||||
|
||||
<div className="text"><strong>If you have any questions or need further assistance, feel free to ask.</strong></div>
|
||||
447
blog/2019-05-29-blog-19.md
Normal file
@ -0,0 +1,447 @@
|
||||
---
|
||||
slug: Creating Your Website Installing the LAMP Stack on Ubuntu 20.04
|
||||
title: Creating Your Website Installing the LAMP Stack on Ubuntu 20.04
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import ubuntu from '@site/static/img/small_apache_default.png'
|
||||
import hello from '@site/static/img/landing_page.png'
|
||||
import php from '@site/static/img/php7.4.13.jpg'
|
||||
import todo from '@site/static/img/todo_list.png'
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">In simple terms, a "LAMP" stack is a bundle of open-source software installed together to make a server capable of hosting dynamic websites and web apps built in PHP. "LAMP" stands for Linux (the operating system), Apache (the web server), MySQL (the database), and PHP (the programming language).</div><br/>
|
||||
|
||||
<div className="text">In this guide, we'll show you how to set up a LAMP stack on an Ubuntu 20.04 server.</div><br/>
|
||||
|
||||
|
||||
<div className="head">What You Need Before Starting</div>
|
||||
<div className="text">Before we start, make sure you have an Ubuntu 20.04 server set up. You'll also need a user account with sudo privileges and a basic firewall. If you haven't done this yet, you can follow our guide for setting up your server.</div><br/>
|
||||
|
||||
<div className="head">Step 1 —Setting Up Apache and Securing Your Connection</div>
|
||||
|
||||
<div className="text">Apache is one of the most popular web servers globally. It's widely used, well-supported, and has been a key part of the internet for a long time. That's why it's a fantastic option for hosting websites.</div><br/>
|
||||
|
||||
<div className="text">Let's get started by updating the package manager cache. If it's your first time using sudo in this session, you'll be asked for your password to confirm that you have the necessary privileges to manage system packages with apt.</div>
|
||||
|
||||
<CodeBlock code={`sudo apt update`} /><br/>
|
||||
|
||||
<div className="text">Next, let's put Apache on your computer! Just type this command and hit enter:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install apache2`} /><br/>
|
||||
|
||||
<div className="text">After you type the command to install Apache, your computer might ask you a question. Just press "Y" on your keyboard and then hit enter.</div><br/>
|
||||
|
||||
<div className="text">Once Apache is finished installing, we need to make sure your computer's security settings allow it to work properly. We'll use something called UFW to do this. UFW has different settings for different types of programs and we'll pick the one for Apache.To see all the different settings UFW has, just type this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app list`} /><br/>
|
||||
|
||||
<div className="text">You'll see some information on your screen that looks like this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Available applications:
|
||||
Apache
|
||||
Apache Full
|
||||
Apache Secure
|
||||
OpenSSH
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Here's what each of these options means:</div>
|
||||
|
||||
<div className="text"><ol><li>Apache: This option allows regular web traffic on port 80, like opening the main door for visitors.</li><li>Apache Full: It allows both regular web traffic (port 80) and secure traffic using TLS/SSL encryption (port 443).</li><li>Apache Secure: This option only opens the special secure door for traffic using TLS/SSL encryption (port 443).</li></ol></div>
|
||||
|
||||
|
||||
<div className="text">For now, it's a good idea to only allow connections through the main door (port 80). Since we just installed Apache and haven't set up a special security certificate yet, it's not ready for secure traffic (HTTPS).</div><br/>
|
||||
|
||||
<div className="text">To do this, we'll use the Apache profile:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw allow in "Apache"`} /><br/>
|
||||
<div className="text">You can make sure everything is working by checking with:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw status`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Status: active
|
||||
|
||||
To Action From
|
||||
-- ------ ----
|
||||
OpenSSH ALLOW Anywhere
|
||||
Apache ALLOW Anywhere
|
||||
OpenSSH (v6) ALLOW Anywhere (v6)
|
||||
Apache (v6) ALLOW Anywhere (v6)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, your firewall is letting traffic through the main door (port 80).
|
||||
To make sure everything is working, you can quickly check by opening your web browser and visiting your server's public IP address. If you're not sure what your public IP address is, there's a note in the next section that will help you find it.</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_ip`} /><br/>
|
||||
|
||||
<div className="text">When you visit your server's address in the web browser, you'll see a special page that comes with Ubuntu 20.04 and Apache. This page is just there to give you information and check if everything is set up correctly. It might look something like this:</div><br/>
|
||||
|
||||
|
||||
<img src={ubuntu} alt="Ubuntu Page" /> <br/>
|
||||
|
||||
<div className="text">If you can see this page, it means your web server is all set up and working properly. You've successfully installed it, and people can now visit your website through the firewall. Good job!</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Finding Your Server's Public IP Address</div>
|
||||
<div className="text">If you're not sure about your server's public IP address (the special code to find your server on the internet), there are a couple of easy ways to check. This is the address you use when you want to connect to your server, for example using SSH.</div><br/>
|
||||
|
||||
<div className="text">One way is to use a tool called "iproute2." It's like a detective tool for your computer. You can find your IP address by typing this command:</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">When you type that command, your computer will show you two or three lines of information. All of them are correct addresses, but your computer might only be able to use one. You can try each one to see which works.</div><br/>
|
||||
|
||||
<div className="text">Another way is to use a tool called "curl." It's like sending a message to a special server and asking, "Hey, what's my IP address?" You can do this by typing a command:</div>
|
||||
|
||||
<CodeBlock code={`curl http://icanhazip.com`} /><br/>
|
||||
|
||||
<div className="text">No matter how you found your IP address, just copy and paste it into the address bar of your web browser. This way, you can check out the default Apache page and see if everything is working as expected.</div><br/>
|
||||
|
||||
<div className="head">Step 2 — Your Database: Installing MySQL</div>
|
||||
|
||||
<div className="text">Now that your web server is ready, let's add the database system. This helps store and manage data for your website. MySQL is a popular choice for this, especially when you're using PHP.</div><br/>
|
||||
|
||||
<div className="text">Just like before, we'll use the "apt" tool to get and install MySQL. It's a simple command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install mysql-server`} /><br/>
|
||||
|
||||
<div className="text">When your computer asks if you want to install MySQL, just type "Y" and press ENTER.</div><br/>
|
||||
|
||||
<div className="text">After the installation, it's a good idea to make things more secure. There's a special tool that comes with MySQL to help with this. It's like a virtual security assistant for your database. To use it, just type a command:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">This will check if you want to set up something called the VALIDATE PASSWORD PLUGIN.</div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: Deciding to turn on this feature is up to you. If you enable it, MySQL will only accept passwords that meet certain criteria. However, it's okay to leave this validation turned off. Just make sure to always use strong and unique passwords for your database – that's important!</div><br/>
|
||||
|
||||
<div className="text">Type "Y" if you want to turn it on, or press any other key if you want to continue without turning it on.</div>
|
||||
|
||||
<CodeBlock code={`VALIDATE PASSWORD PLUGIN can be used to test passwords
|
||||
and improve security. It checks the strength of password
|
||||
and allows the users to set only those passwords which are
|
||||
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
|
||||
|
||||
Press y|Y for Yes, any other key for No:
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you say "yes," you'll need to choose how strict you want the password rules to be. If you pick level 2 for the strongest rules, keep in mind that your passwords must have numbers, both upper and lower case letters, special characters, or should not be common words. If this sounds a bit confusing or strict, you can choose a lower level for simpler rules.</div>
|
||||
|
||||
<CodeBlock code={`There are three levels of password validation policy:
|
||||
|
||||
LOW Length >= 8
|
||||
MEDIUM Length >= 8, numeric, mixed case, and special characters
|
||||
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
|
||||
|
||||
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Whether you decided to use the password check feature or not, your server will now ask you to choose and confirm a password for the MySQL root user. This is different from the system root. The database root user is like a super admin with full control over the database system.Even though MySQL usually doesn't need a password for the root user by default, it's safer to set a strong password here. We'll discuss why in a moment</div><br/>
|
||||
|
||||
<div className="text">If you turn on password validation, you'll see how strong your root password is. Your server will then ask if you want to keep that password. If you're happy with it, just type "Y" for "yes" when prompted.</div>
|
||||
|
||||
<CodeBlock code={`Estimated strength of the password: 100
|
||||
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">For the remaining questions, just press "Y" and then press the ENTER key each time. This will remove some unnecessary users and databases, make sure remote logins are secure, and apply these changes to MySQL right away.</div><br/>
|
||||
|
||||
<div className="text">Once you're done, let's check if you can log in to the MySQL console. Just type:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql`} /><br/>
|
||||
|
||||
<div className="text">This command will connect you to the MySQL server as the main admin user, called "root." This is automatically done using special permission ("sudo") when you run the command. You'll see some information displayed on your screen, which should look like this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Welcome to the MySQL monitor. Commands end with ; or \g.
|
||||
Your MySQL connection id is 22
|
||||
Server version: 8.0.19-0ubuntu5 (Ubuntu)
|
||||
|
||||
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
Oracle is a registered trademark of Oracle Corporation and/or its
|
||||
affiliates. Other names may be trademarks of their respective
|
||||
owners.
|
||||
|
||||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
||||
|
||||
mysql>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To leave the MySQL console, just type:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Even though you set a password during the setup, you might notice that you didn't have to enter it when logging in as the root user. This might seem unusual, but it's actually a security feature. The default way to log in as the main MySQL admin is a bit different – it uses the system's authentication instead of a password. This makes your database server more secure because only users with special permissions (like sudo privileges) can log in as the root MySQL user. In simple terms, you won't be using this root user directly for your website. The password you set is like a backup plan, just in case the default login method changes in the future.</div><br/>
|
||||
|
||||
<div className="text">To make things more secure, it's a good idea to create separate user accounts for each database, especially if you're planning to have more than one database on your server. This way, each database has its own special access, and it helps keep everything safer.</div><br/>
|
||||
|
||||
<div className="note"><strong>Note : </strong>As of now, the standard library used by PHP for MySQL doesn't work perfectly with the default way MySQL 8 checks passwords. So, when you're setting up users for your PHP applications, you'll need to configure them to use a specific method called "mysql_native_password." We'll show you how to do that later on.</div>
|
||||
|
||||
<div className="text">Your MySQL server is all set up and safe. Now, let's move on to installing PHP, which is the last piece needed for the LAMP stack.</div><br/>
|
||||
|
||||
<div className="head">Step 3 - Adding PHP to Your Setup</div>
|
||||
|
||||
<div className="text">Now that your server can show web pages and manage data, let's bring in PHP. This is what makes your website do cool things by processing code. To make it work smoothly, we'll install the "php" package. Also, we need "php-mysql" to let PHP talk to MySQL, and "libapache2-mod-php" to help Apache handle PHP files. Don't worry about these names; they'll be installed automatically.</div><br/>
|
||||
|
||||
<div className="text">Just type this command to get everything set up:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install php libapache2-mod-php php-mysql`} /><br/>
|
||||
|
||||
<div className="text">After everything is installed, you can check your PHP version by typing the following command:</div>
|
||||
|
||||
<CodeBlock code={`php -v`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
PHP 7.4.3 (cli) (built: Jul 5 2021 15:13:35) ( NTS )
|
||||
Copyright (c) The PHP Group
|
||||
Zend Engine v3.4.0, Copyright (c) Zend Technologies
|
||||
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Now that your LAMP stack is up and running, it's almost ready for your website. But before you test it with a PHP script, let's make sure everything is organized. We'll set up a special space in Apache called a "Virtual Host" to hold all your website's files and folders. We'll do that in the next step.</div><br/>
|
||||
|
||||
<div className="head">Step 4 - Organizing Your Website: Creating a Virtual Host</div>
|
||||
|
||||
<div className="text">When you're running a website using the Apache web server, you can create something called virtual hosts. These are like individual compartments that hold all the settings for a specific website. They allow you to host more than one website on a single server. In this guide, we'll set up a pretend domain called your_domain. But remember, you should use your own domain name instead of "your_domain". Let's get started!</div><br/>
|
||||
|
||||
<div className="text">Apache on Ubuntu 20.04 comes with a default setup that serves web pages from a directory called /var/www/html. This works fine if you only have one website. However, if you want to host multiple websites, it can get messy. Instead of changing the default setup, we'll create a new directory for each website within the /var/www folder. This way, the /var/www/html directory will still be there to serve pages if no specific website is requested.</div><br/>
|
||||
|
||||
<div className="text">To do this for your_domain, follow these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo mkdir /var/www/your_domain`} /><br/>
|
||||
|
||||
<div className="text">Next, we need to give you control over the directory we just created. To do this, we'll use a special code that references your username on the system. This ensures that you have the necessary permissions to manage the files and folders inside.</div>
|
||||
|
||||
<CodeBlock code={`sudo chown -R $USER:$USER /var/www/your_domain`} /><br/>
|
||||
|
||||
<div className="text">Next, we'll open a new file where we can configure our website settings. We'll do this in a specific directory where Apache keeps these configuration files. We'll use a basic text editor called nano for this task.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/sites-available/your_domain.conf`} /><br/>
|
||||
|
||||
<div className="text">This will make a new empty file where we can put some basic settings for our website. Copy and paste the following simple configuration into this file.</div>
|
||||
|
||||
<CodeBlock code={`<VirtualHost *:80>
|
||||
ServerName your_domain
|
||||
ServerAlias www.your_domain
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/your_domain
|
||||
ErrorLog $ {APACHE_LOG_DIR}/error.log
|
||||
CustomLog $ {APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, to save and close the file, if you're using the nano editor, press CTRL+X, then Y, and finally ENTER.</div><br/>
|
||||
|
||||
<div className="text">With this configuration, Apache knows to use the /var/www/your_domain folder as the place to find the files for your website. If you don't have a domain name yet or just want to test things out, you can ignore the ServerName and ServerAlias options for now.</div><br/>
|
||||
|
||||
<div className="text">Once you've saved and closed the file, you can activate the new virtual host by running the command:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2ensite your_domain`} /><br/>
|
||||
|
||||
<div className="text">If you're not using a custom domain name, you may want to turn off the default website that Apache comes with. This is important because otherwise, Apache's default setup will take precedence over your new virtual host.</div><br/>
|
||||
|
||||
<div className="text">To do this, you just need to type the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2dissite 000-default`} /><br/>
|
||||
|
||||
<div className="text">To double-check that there are no mistakes in your configuration file, you can run the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apache2ctl configtest`} /><br/>
|
||||
|
||||
<div className="text">Finally, to apply these changes and make them active, you just need to reload Apache. You can do this by running the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl reload apache2`} /><br/>
|
||||
|
||||
<div className="text">Your new website is up and running, but there's nothing in the web folder yet. To test if everything is working correctly, we'll create a simple web page. Navigate to the /var/www/your_domain directory, and create a new file called index.html. This file will contain the content of your webpage.</div>
|
||||
|
||||
<CodeBlock code={`nano /var/www/your_domain/index.html`} /><br/>
|
||||
|
||||
<div className="text">Inside the index.html file, add the following content:</div>
|
||||
|
||||
<CodeBlock code={`<html>
|
||||
<head>
|
||||
<title>your_domain website</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
<p>This is the landing page of <strong>your_domain</strong>.</p>
|
||||
</body>
|
||||
</html>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, open your web browser and type in the domain name or IP address of your server just like you did before. This will allow you to see if your website is now accessible and displaying the content you added to the index.html file.</div>
|
||||
|
||||
<CodeBlock code={`http://server_domain_or_IP`} /><br/>
|
||||
|
||||
<div className="text">You should see a page that looks like this:</div><br/>
|
||||
|
||||
<img src={hello} alt="landing Page" /> <br/>
|
||||
|
||||
<div className="text">If you're seeing this page, it confirms that your Apache virtual host is set up correctly.</div><br/>
|
||||
|
||||
<div className="text">You can keep this index.html file as a temporary landing page for your website until you're ready to replace it with an index.php file if you're using PHP. Once you've set up your index.php file, make sure to delete or rename the index.html file from your website's main folder. Otherwise, the index.html file will show up instead of your index.php file when someone visits your website.</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Understanding DirectoryIndex in Apache Web Server</div>
|
||||
|
||||
<div className="text">By default, Apache gives priority to a file named index.html over an index.php file. This can be handy for showing maintenance pages on your website. For example, if you need to do some updates on your PHP application, you can create a temporary index.html file with a message for visitors. Since Apache will show index.html first, it becomes the main page during maintenance. After you're done, just rename or delete index.html, and your PHP application will be back as the main page.</div><br/>
|
||||
|
||||
<div className="text">If you want to switch this behavior, you'll have to adjust the configuration in a file called dir.conf located in the /etc/apache2/mods-enabled/ directory. This file controls the order in which Apache looks for default files like index.php or index.html when someone visits your website. You can change the order here to prioritize index.php over index.html if you prefer.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/mods-enabled/dir.conf
|
||||
<IfModule mod_dir.c>
|
||||
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After you've made the changes to the dir.conf file and saved it, you need to reload Apache to apply these changes. This ensures that Apache follows the new order you've set for default files like index.php or index.html.</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl reload apache2`} /><br/>
|
||||
|
||||
<div className="text">Next, we'll make a simple PHP script to make sure PHP is working properly on your server. This script will help us confirm that PHP is installed and set up correctly.</div><br/>
|
||||
|
||||
<div className="head">Step 5 — Checking PHP Setup: Testing PHP Processing on Your Web Server</div>
|
||||
|
||||
<div className="text">Now, we'll make a special file to check if PHP is working on your server. This file will help us see if Apache can correctly handle and process PHP files.</div><br/>
|
||||
|
||||
<div className="text">Simply create a new file called info.php inside the folder where you put your website's files.</div>
|
||||
|
||||
<CodeBlock code={`nano /var/www/your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">When the file is opened, copy and paste the following text. This text contains code that PHP can understand and execute.</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
phpinfo();
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've added the code, save and close the file.<br/><br/>
|
||||
Now, to test if everything is working correctly, open your web browser and type in your server's domain name or IP address, followed by "/info.php" in the address bar. This will allow you to see if the PHP script runs as expected.</div>
|
||||
|
||||
<CodeBlock code={`http://server_domain_or_IP/info.php`} /><br/>
|
||||
|
||||
<div className="text">You should see a page that looks like this:</div><br/>
|
||||
|
||||
<img src={php} alt="php Page" /> <br/>
|
||||
|
||||
<div className="text">This page shows details about your server as seen by PHP. It's helpful for troubleshooting and making sure your settings are correct.</div><br/>
|
||||
|
||||
<div className="text">If you can view this page in your browser, it means PHP is set up correctly on your server.</div><br/>
|
||||
|
||||
<div className="text">After you've checked the information on the page, it's a good idea to delete the file you created. This is because it contains sensitive details about your PHP setup and your server. You can remove it using the command "rm":</div>
|
||||
|
||||
<CodeBlock code={`sudo rm /var/www/your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">If you ever need to see this information again, you can easily recreate the page. So don't worry about deleting it now. If you need the details in the future, you can just make the file again.</div>
|
||||
|
||||
<CodeBlock code={`Step 6 — Checking Database Connection with PHP (Optional)`} /><br/>
|
||||
|
||||
<div className="text">If you're interested in seeing if PHP can communicate with MySQL and perform database operations, you can set up a simple test. First, we'll create a test database and a new MySQL user with the right permissions to access it. This will ensure everything is set up properly before proceeding.</div><br/>
|
||||
|
||||
<div className="text">As of now, the built-in MySQL PHP library called mysqlnd doesn't work with the default authentication method (caching_sha2_authentication) used in MySQL 8. So, we have to create a new user with a different authentication method (mysql_native_password) to make sure PHP can connect to the MySQL database correctly.</div> <br/>
|
||||
|
||||
<div className="text">Let's create a database called "example_database" and a user named "example_user". But if you prefer different names, feel free to choose them.</div><br/>
|
||||
|
||||
<div className="text">To start, let's open the MySQL console using the root account.</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql`} /><br/>
|
||||
<div className="text">To make a new database, type the following command into your MySQL console:</div><br/>
|
||||
|
||||
<div className="text">CREATE DATABASE example_database;</div><br/>
|
||||
|
||||
<div className="text">Now, let's create a new user and give them full access to the database we just made.<br/>
|
||||
Use the following command to create a new user named "example_user". We'll set their default authentication method to "mysql_native_password". We'll also assign the password "password" to this user. However, for security reasons, it's crucial to replace "password" with a strong, unique password of your choice.</div>
|
||||
|
||||
<CodeBlock code={`CREATE USER 'example_user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';`} /><br/>
|
||||
|
||||
<div className="text">Next, we have to grant permission to the "example_user" over the "example_database" database. This allows the user to perform operations on this database.</div>
|
||||
|
||||
<CodeBlock code={`GRANT ALL ON example_database.* TO 'example_user'@'%';`} /><br/>
|
||||
|
||||
<div className="text">With this command, the "example_user" will have complete control over the "example_database" database, but they won't be able to make changes to other databases on your server.<br/> <br/> To leave the MySQL shell, simply type:</div><br/>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">To check if the new user has the correct permissions, you can log in to the MySQL console again, but this time using the credentials of the user you just created.</div>
|
||||
|
||||
<CodeBlock code={`mysql -u example_user -p`} /><br/>
|
||||
|
||||
<div className="text">In this command, you'll see the "-p" flag, which means MySQL will ask you to enter the password for the "example_user" you created earlier. Once you've logged in to the MySQL console, check if you can access the "example_database" database.</div>
|
||||
|
||||
<CodeBlock code={`SHOW DATABASES;`} /><br/>
|
||||
|
||||
<div className="text">After running the command, you should see something like this on your screen:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+--------------------+
|
||||
| Database |
|
||||
+--------------------+
|
||||
| example_database |
|
||||
| information_schema |
|
||||
+--------------------+
|
||||
2 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Next, we're going to make a test table called "todo_list". Go back to your MySQL console and type in the following command:</div>
|
||||
|
||||
<CodeBlock code={`CREATE TABLE example_database.todo_list (
|
||||
item_id INT AUTO_INCREMENT,
|
||||
content VARCHAR(255),
|
||||
PRIMARY KEY(item_id)
|
||||
);
|
||||
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've checked that your test table has the correct data, you can leave the MySQL console by typing:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make the PHP script that connects to MySQL and retrieves your data. To do this, create a new file in the folder where your website's files are stored. We'll use a simple text editor called nano for this task.</div>
|
||||
|
||||
<CodeBlock code={`nano /var/www/your_domain/todo_list.php`} /><br/>
|
||||
|
||||
<div className="text">Below is a PHP script that connects to your MySQL database, retrieves the content of the todo_list table, and displays the results in a list format. If there's an issue with the database connection, it will show an error message.</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
$user = "example_user";
|
||||
$password = "password";
|
||||
$database = "example_database";
|
||||
$table = "todo_list";
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
|
||||
echo "<h2>TODO</h2><ol>";
|
||||
foreach($db->query("SELECT content FROM $table") as $row) {
|
||||
echo "<li>" . $row['content'] . "</li>";
|
||||
}
|
||||
echo "</ol>";
|
||||
} catch (PDOException $e) {
|
||||
print "Error!: " . $e->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've finished editing the file, save and close it.</div><br/>
|
||||
|
||||
<div className="text">Now, you can view this page in your web browser by entering your website's domain name or public IP address, followed by "/todo_list.php".</div>
|
||||
|
||||
<CodeBlock code={`http://your_domain_or_IP/todo_list.php`} /><br/>
|
||||
|
||||
<div className="text">When you visit the page in your web browser, you should see something similar to this, displaying the content you added to your test table:</div><br/>
|
||||
|
||||
<img src={todo} alt="todo Page" /> <br/>
|
||||
|
||||
<div className="text">This indicates that your PHP setup is working correctly and can communicate with your MySQL server.</div><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">In this guide, you've set up a reliable system for hosting PHP websites and applications using Apache as your web server and MySQL as your database. Now, it's important to make sure your website connections are secure. You can do this by enabling HTTPS, which encrypts data between your website and your visitors' browsers. To do this easily and for free, you can use Let’s Encrypt to get a TLS/SSL certificate.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to secure your website? Check out our guide on how to set up HTTPS with Let’s Encrypt.</strong></div>
|
||||
153
blog/2019-05-29-blog-2.md
Normal file
@ -0,0 +1,153 @@
|
||||
---
|
||||
slug: How to Get Rid of Things in Docker Images, Containers and Volumes Cleanup Made Simple!
|
||||
title: How to Get Rid of Things in Docker Images, Containers and Volumes Cleanup Made Simple!
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="text">Welcome to Docker! Docker helps you neatly pack your apps in containers, making them easy to move around. But sometimes, you end up with extra stuff like pictures, boxes, and data stacks taking up space on your computer.
|
||||
No worries! Docker has a trick in its toolbox. You can clean up using some easy commands from your computer's taking place (the command line). This guide is like a Quick Guide – it gives you quick tips to free up space and keep your computer tidy by tossing out the unnecessary Docker pictures, boxes, and data stacks.</div> <br/>
|
||||
|
||||
<span className="custom-text">How to Use This Quick Guide:</span>
|
||||
<div className="text">Think of it as a quick reference with simple commands. If you want to do something specific, find that part. Let's keep it simple and neat! </div><br/>
|
||||
<div className="text"> <strong>Note: </strong>The way we use commands like $(command) is supported in popular shells such as bash, zsh and Windows Powershell. It's like a language these shells understand to get things done! </div>
|
||||
<div className="head">Getting Rid of Unused Stuff in Docker: </div>
|
||||
<div className="text">Docker can help clean up your computer easily! Just one command clears things like extra pictures, boxes, data and connections hanging out without labels or buddies (not tagged or associated with a container). Let's see how to do this super quickly! </div> <br/>
|
||||
<CodeBlock code={`docker system prune
|
||||
`} />
|
||||
<div className="text">To also clear out any stopped containers and all unnecessary images (not just the dangling ones), just add the -a flag to the command! </div> <br/>
|
||||
<CodeBlock code={`docker system prune -a
|
||||
`} />
|
||||
<div className="head">Getting Rid of Docker Images</div>
|
||||
<div className="text">Eliminate one or more specific images <br/> <br/>
|
||||
To locate the images you want to remove, use the docker images command with the -a flag. This displays all images, including the ones in-between. Once you spot the images you want to erase, use their ID or tag with docker rmi. It's as simple as that! </div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker images -a
|
||||
`} /> <br/>
|
||||
<strong>Remove:</strong>
|
||||
<CodeBlock code={`docker rmi Image Image
|
||||
`} />
|
||||
<div className="head">Cleaning Up Unused Images</div>
|
||||
<div className="text">Docker images are like building blocks made up of multiple layers. Dangling images are like lonely blocks that don't connect to anything important. They do nothing useful and take up space on your computer. You can find them using a special command: add -f with the secret code "dangling=true" to the docker images command. When you're ready to remove them, use the docker image prune command. Easy peasy! <br/> <br/>
|
||||
<strong>Note: </strong>When you create a special Docker image, it might end up feeling a bit lost if you forget to give it a name (tag). These unnamed images show up in a list called "dangling images" because they don't have a buddy with a name. To avoid this, simply give your image a name when you create it. If you forget, don't worry! You can always give it a name later using the docker tag command. Easy, right?</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker images -f dangling=true
|
||||
`} /> <br/>
|
||||
<strong>Remove:</strong>
|
||||
<CodeBlock code={`docker image prune
|
||||
`} />
|
||||
<div className="head">Deleting Images with a Search</div>
|
||||
<div className="text">If you want to clean up a bunch of images that share a common theme, you can use a mix of docker pictures and a tool called grep. Once you're sure about the ones you want to remove, you can make them disappear using a special command called awk, which talks to docker rmi. Just remember, these tools aren't part of Docker itself, so they might not work the same way on every computer. But if you have them, you're good to go!</div> <br/>
|
||||
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker images -a | grep "pattern"
|
||||
`} /> <br/>
|
||||
<strong>Remove:</strong>
|
||||
<CodeBlock code={`docker images -a | grep "pattern" | awk '{print $3}' | xargs docker rmi
|
||||
`} />
|
||||
<div className="head">Deleting All Images</div>
|
||||
<div className="text">If you want to get rid of all the Docker pictures on your computer, you can see a list of them by typing docker images -a. Once you're sure you want to say goodbye to all of them, just use a special command by adding -q to the docker images -a command. It's like cleaning up your entire picture collection in one go!</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker images -a
|
||||
`} /> <br/>
|
||||
<strong>Delete:</strong>
|
||||
<CodeBlock code={`docker rmi $(docker images -a -q)
|
||||
`} />
|
||||
|
||||
<div className="head">Removing Containers</div>
|
||||
<div className="text">Deleting Specific Containers <br/>
|
||||
If you're looking to tidy up your digital space by removing specific containers, you're in luck! Discover how to find their names or IDs using the straightforward command docker ps -a. Once you've identified the ones you want to remove, you're all set for a cleaner digital environment.</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker ps -a
|
||||
`} /> <br/>
|
||||
<strong>Remove:</strong>
|
||||
<CodeBlock code={`docker rm ID_or_Name ID_or_Name
|
||||
`} />
|
||||
|
||||
<div className="head">Deleting a Container Automatically</div>
|
||||
<div className="text">If you're pretty sure you won't need a container after you finish using it, you can make life easy! Just use the command docker run --rm. It's like telling Docker to automatically clean up after itself once you're done using the container. Simple, right?</div> <br/>
|
||||
<strong>Run and Delete:</strong>
|
||||
<CodeBlock code={`docker run --rm image_name
|
||||
`} />
|
||||
|
||||
<div className="head">Deleting All Finished Containers</div>
|
||||
<div className="text">To find containers that are finished doing their job, type docker ps -a. You can sort them by their status: created, restarting, running, paused, or exited. To see only the ones that are finished, use a special code called -f to filter them. Once you're sure you want to get rid of these containers, use another code called -q to make them disappear with docker rm. It's like cleaning up after your containers finish their work!</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker ps -a -f status=exited
|
||||
`} /> <br/>
|
||||
<strong>Delete:</strong>
|
||||
<CodeBlock code={`docker rm $(docker ps -a -f status=exited -q)
|
||||
`} />
|
||||
|
||||
<div className="head">Deleting Containers with Multiple Conditions</div>
|
||||
<div className="text">You can use different codes to find and remove specific containers. It's like sorting through your containers based on different things. If you want to delete containers that are either just created or finished doing their job, you can use two special codes together. It's as simple as that!</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker ps -a -f status=exited -f status=created
|
||||
`} /> <br/>
|
||||
<strong>Delete:</strong>
|
||||
<CodeBlock code={`docker rm $(docker ps -a -f status=exited -f status=created -q)
|
||||
`} />
|
||||
|
||||
<div className="head">Deleting Containers with a Search</div>
|
||||
<div className="text">If you want to clean up containers that share a common theme, you can use a mix of docker list and a tool called grep. Once you're sure about the ones you want to remove, you can make them disappear using special commands called awk and xargs with docker rm. Just remember, these tools might not work the same way on every computer because they're not part of Docker itself. But if you have them, you're good to go!</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker ps -a | grep "pattern”
|
||||
`} /> <br/>
|
||||
<strong>Delete:</strong>
|
||||
<CodeBlock code={`docker ps -a | grep "pattern" | awk '{print $1}' | xargs docker rm
|
||||
`} />
|
||||
|
||||
<div className="head">Stopping and Clearing All Containers</div>
|
||||
<div className="text">Wondering what containers are hanging out on your computer? Just type docker ps to see them. Add a little magic code, -a, to see all of them. When you're certain you want to make them vanish, use another secret code, -q, to stop and remove them with two special commands: docker stop and docker rm. It's like giving your computer a quick clean-up!</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker ps -a
|
||||
`} /> <br/>
|
||||
<strong>Remove:</strong>
|
||||
<CodeBlock code={`docker stop $(docker ps -a -q)
|
||||
docker rm $(docker ps -a -q)
|
||||
`} />
|
||||
|
||||
<div className="head">Deleting Volumes</div>
|
||||
<div className="text">Getting rid of specific volumes in Docker 1.9 and later is simple! <br/> <br/>First, use docker volume ls to find the name or names of the volumes you want to remove. Then, make them disappear by using docker volume rm. It's like saying goodbye to the storage spaces you no longer need!</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker volume ls
|
||||
`} /> <br/>
|
||||
<strong>Delete:</strong>
|
||||
<CodeBlock code={`docker volume rm volume_name volume_name
|
||||
`} />
|
||||
|
||||
<div className="head">Deleting Unused Volumes</div>
|
||||
<div className="text">In Docker 1.9 and later versions, volumes stick around even after containers are gone. When a volume is no longer connected to any containers, it's called a dangling volume. To find these and make sure you want to remove them, use docker volume ls with a special code to show only the dangling volumes. Once you're sure, get rid of them all with docker volume prune. It's like cleaning up extra storage space you don't need anymore!</div> <br/>
|
||||
<strong>List:</strong>
|
||||
<CodeBlock code={`docker volume ls -f dangling=true
|
||||
`} /> <br/>
|
||||
<strong>Delete:</strong>
|
||||
<CodeBlock code={`docker volume prune
|
||||
`} />
|
||||
|
||||
<div className="head">Deleting a Container and its Volume</div>
|
||||
<div className="text">IIf you made a volume without giving it a name, you can delete it when you remove the container by using a special code, -v. Remember, this trick only works for volumes without names. Once the container is gone, you'll see its ID, but there won't be any mention of the volume. If the volume is unnamed, it quietly disappears. If it has a name, it stays on your system silently. It's like cleaning up your digital space effortlessly!</div> <br/>
|
||||
|
||||
<strong>Delete:</strong>
|
||||
<CodeBlock code={`docker rm -v container_name
|
||||
`} /> <br/>
|
||||
<div className="con">Conclusion:</div>
|
||||
<div className="text">In this guide, we've shown you the basics of cleaning up in Docker. But there's a whole world of cleanup options waiting for you! Check out Docker's documentation for commands like docker system prune, docker rmi, docker rm and docker volume rm to explore more. <br/> <br/><strong>Have questions or want to share your cleanup ideas? <br/><br/>Drop a comment below! We're here to help you keep things neat and tidy in your Docker world.</strong></div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
58
blog/2019-05-29-blog-20.md
Normal file
@ -0,0 +1,58 @@
|
||||
---
|
||||
slug: Installing Apache, MySQL, PHP (LAMP) Stack on Ubuntu 22.04
|
||||
title: Installing Apache, MySQL, PHP (LAMP) Stack on Ubuntu 22.04
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">A "LAMP" stack is a bundle of free software commonly installed together to make a server capable of hosting dynamic websites and web apps built with PHP. LAMP stands for Linux (the operating system), Apache (the web server), MySQL (the database), and PHP (the scripting language).</div><br/>
|
||||
|
||||
<div className="text">In this guide, we'll help you set up a LAMP stack on a server running Ubuntu 22.04.</div><br/>
|
||||
|
||||
|
||||
<div className="head">What You'll Need Before Starting</div>
|
||||
|
||||
<div className="text">Before we start, make sure you have an Ubuntu 22.04 server set up. You'll also need a user account with sudo privileges and a basic firewall. If you haven't done this yet, you can follow our beginner-friendly guide on setting up your Ubuntu 22.04 server.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Step 1: Setting Up Apache and Firewall</div>
|
||||
|
||||
<div className="text">Apache is a widely used web server that's trusted by many website owners. It's well-supported and has been around for a long time, making it a solid choice for hosting your website.</div><br/>
|
||||
|
||||
<div className="text">Let's begin by updating the list of available software packages. If you're using the sudo command for the first time during this session, you'll be asked to enter your password to confirm that you have permission to install software on your system.</div>
|
||||
|
||||
<!-- <CodeBlock code={`sudo apt update`} /><br/> -->
|
||||
|
||||
|
||||
<!-- <div className="text">Next, install Apache by typing:</div> -->
|
||||
|
||||
<!-- <CodeBlock code={`sudo apt install apache2`} /><br/> -->
|
||||
|
||||
<!-- <div className="text">You'll be asked to confirm the installation of Apache. Just press Y, then ENTER to proceed.</div><br/> -->
|
||||
|
||||
<!-- <div className="text">After Apache is installed, you'll need to adjust your firewall settings to allow web traffic. Ubuntu uses a firewall tool called Uncomplicated Firewall (UFW). It comes with various application profiles you can use. To see a list of these profiles, run the following command:</div> -->
|
||||
|
||||
<!-- <CodeBlock code={`sudo ufw app list`} /><br/> -->
|
||||
|
||||
<!-- <CodeBlock code={`Output
|
||||
Available applications:
|
||||
Apache
|
||||
Apache Full
|
||||
Apache Secure
|
||||
OpenSSH
|
||||
`} /><br/> -->
|
||||
|
||||
<!-- <div className="text">Understanding Apache Firewall Profiles:</div> -->
|
||||
|
||||
<!-- <div className="text"><ol><li>Apache: Allows regular web traffic through port 80.</li><li>Apache Full: Allows both regular web traffic through port 80 and encrypted web traffic through port 443 (TLS/SSL).</li><li>Apache Secure: Allows only encrypted web traffic through port 443 (TLS/SSL)</li></ol></div> -->
|
||||
|
||||
|
||||
|
||||
|
||||
402
blog/2019-05-29-blog-21.md
Normal file
@ -0,0 +1,402 @@
|
||||
---
|
||||
slug: Complete Guide Installing LAMP Stack on Debian 11
|
||||
title: Complete Guide Installing LAMP Stack on Debian 11
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import debian from '@site/static/img/debian.png';
|
||||
import debian11 from '@site/static/img/debian11.png';
|
||||
import todo from '@site/static/img/todo_list.png';
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">A 'LAMP' stack is a group of open-source software that is commonly installed together to allow a server to host dynamic websites and web apps. This term stands for:
|
||||
Linux: the operating system,
|
||||
Apache: the web server,
|
||||
MariaDB: the database where website data is stored,
|
||||
PHP: the language used to create dynamic content.</div><br/>
|
||||
|
||||
<div className="text">While MySQL is often used as the database management system, some Linux distributions, like Debian, use MariaDB as a replacement. In this guide, you'll learn how to install a LAMP stack on a Debian 11 server, using MariaDB as the database management system.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Preparing Your Debian 11 Server</div>
|
||||
|
||||
<div className="text">Before we start, make sure you have a Debian 11 server ready. You'll also need a user account with sudo privileges and a basic firewall set up. If you haven't done this yet, you can check our beginner's guide on setting up your Debian 11 server for help.</div><br/>
|
||||
|
||||
<div className="head">Step 1 - Apache Installation and Firewall Update</div>
|
||||
<div className="text">Apache is one of the most popular web servers worldwide. It's well-supported, has a large community, and has been used for hosting websites for a long time, making it a reliable choice.</div><br/>
|
||||
|
||||
<div className="text">Let's begin by updating the package manager cache. If this is your first time using 'sudo' in this session, you'll need to enter your password to confirm you have the necessary permissions to manage system packages with 'apt'.</div>
|
||||
|
||||
<CodeBlock code={`sudo apt update `} /><br/>
|
||||
|
||||
<div className="text">Next, let's install Apache. You can do this by running the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install apache2`} /><br/>
|
||||
|
||||
|
||||
<div className="text">After running the installation command, you'll be asked to confirm if you want to install Apache. Simply type 'Y' and press ENTER to proceed. Once Apache is installed, we need to make sure our firewall allows web traffic. If you've followed our initial server setup guide and enabled the UFW firewall, you'll need to allow HTTP and HTTPS traffic through it.</div><br/>
|
||||
|
||||
<div className="text">On Debian 11, UFW has predefined profiles for applications. You can see the full list of these profiles by running:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app list`} /><br/>
|
||||
|
||||
<div className="text">The WWW profiles you see listed are for controlling the ports that web servers use.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Available applications:
|
||||
. . .
|
||||
WWW
|
||||
WWW Cache
|
||||
WWW Full
|
||||
WWW Secure
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you check the details of the "WWW Full" profile using the command 'ufw app info', you'll see that it allows traffic to go through ports 80 and 443.</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app info "WWW Full"`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Profile: WWW Full
|
||||
Title: Web Server (HTTP,HTTPS)
|
||||
Description: Web Server (HTTP,HTTPS)
|
||||
|
||||
Ports:
|
||||
80,443/tcp
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's enable incoming HTTP and HTTPS traffic for this profile:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw allow in "WWW Full"`} /><br/>
|
||||
|
||||
<div className="text">To confirm that everything is working correctly, open your web browser and visit your server's public IP address.</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_ip`} /><br/>
|
||||
|
||||
<div className="text">You'll see the default Apache web page for Debian 11, which is there to give you some basic information and to test that Apache is working properly.</div><br/>
|
||||
|
||||
<img src={debian} alt="Debain" /> <br/>
|
||||
|
||||
<div className="text">If you see this page in your browser, it means your web server is installed correctly and can be accessed through your firewall.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Finding Your Server's Public IP Address</div>
|
||||
|
||||
<div className="text">Finding your server's public IP address is essential for accessing it from other devices or services. Here are some simple methods to do so: Using Command Line Tools: You can use the command line to find your IP address. One way is to utilize the iproute2 tools. Using Online Services: Alternatively, you can visit a website that displays your public IP address. Simply open your web browser and search for "what is my IP address," and you'll find various websites that provide this information.</div><br/>
|
||||
|
||||
<div className="text">Once you have your server's public IP address, you can use it to connect to your server through SSH or access it via a web browser.</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">When you run the command to find your server's IP address, you might see two or three lines of information. Each line represents a different address, but your computer may only use one of them. You can try each one to see which works.</div><br/>
|
||||
|
||||
<div className="text">Another way to find your IP address is by using the curl utility to ask an outside server. Here's how to do it:</div>
|
||||
|
||||
<CodeBlock code={`curl http://icanhazip.com`} /><br/>
|
||||
|
||||
<div className="text">Choose any method you like and use it to find your IP address. Then, enter this IP address into your web browser to check if your server is showing the default Apache page.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Step 2: Setting Up Your Database with MariaDB</div>
|
||||
|
||||
<div className="text">Now that your website is live on the web server, you need a database system to store and organize data for your site.<br/><br/>
|
||||
In Debian 11, the package used to install MySQL server has been replaced by default-mysql-server, which actually installs MariaDB. MariaDB is a community version of MySQL. To put it simply, when you install default-mysql-server, you're getting MariaDB by default. It's the recommended choice for MySQL-compatible databases on Debian-based systems.</div><br/>
|
||||
|
||||
<div className="text">For better compatibility in the long run, it's suggested to install MariaDB directly using its actual package, which is called "mariadb-server".</div><br/>
|
||||
|
||||
<div className="text">To install MariaDB, simply enter the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install mariadb-server`} /><br/>
|
||||
|
||||
<div className="text">Once the installation is complete, it's a good idea to run a security script that's included with MariaDB. This script helps to improve the security of your database by removing some insecure default settings and restricting access.To start the interactive security script, run the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">This script will guide you through a series of questions to improve the security of your MariaDB setup. The first question will ask for the current database root password. It's important to note that this is not the same as the system root password. The database root user is an administrative user with full control over the database system. Since you've just installed MariaDB and haven't set a password yet, simply press ENTER when prompted.</div><br/>
|
||||
|
||||
<div className="text">Next, you'll be asked if you want to set a password for the database root user. MariaDB uses a secure authentication method for the root user by default, so you don't need to set a password at this time. Simply type 'N' for "No" and then press ENTER.</div><br/>
|
||||
|
||||
<div className="text">After that, you can press 'Y' and then ENTER to accept the default settings for the remaining questions. This will remove any anonymous users and the test database, disable remote root login, and apply these changes immediately so that MariaDB will enforce the new rules you've set.</div><br/>
|
||||
|
||||
<div className="text">Once you've completed the security script, you can log in to the MariaDB console.</div>
|
||||
|
||||
<CodeBlock code={`sudo mariadb`} /><br/>
|
||||
|
||||
<div className="text">When you run this command, it will connect you to the MariaDB server as the administrative user 'root'. This is implied by using 'sudo' with the command.You should see output similar to the following:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
||||
Your MariaDB connection id is 41
|
||||
Server version: 10.5.15-MariaDB-0+deb11u1 Debian 11
|
||||
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
|
||||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
||||
MariaDB [(none)]>
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">You may have noticed that you didn't need to enter a password to connect as the root user. This is because the default way MariaDB authenticates the administrative user 'root' is through the system's authentication method, not with a password. While this might seem concerning initially, it actually enhances security. Only system users with sudo privileges can log in as the MariaDB root user, either directly from the console or through an application running with those same privileges. In simple terms, this means you won't be able to use the MariaDB root user to connect from a PHP application, which is a good security measure.</div><br/>
|
||||
|
||||
<div className="text">For better security, it's recommended to create separate user accounts with limited privileges for each database, especially if you're hosting multiple databases on your server.<br/>
|
||||
To exit the MariaDB console, simply type:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now that your MariaDB server is all set up and secure, it's time to add the final part to our website-building process: PHP</div><br/>
|
||||
|
||||
<div className="head">Step 3 — Adding PHP to Your Server</div>
|
||||
|
||||
<div className="text">Now that you have Apache to show your website and MariaDB to store your data, it's time to add PHP. PHP is like the behind-the-scenes worker of your setup. It takes care of processing code to show dynamic content on your website. It can run scripts, talk to your MariaDB databases to get information and then pass that information to your web server to display on the website.</div><br/>
|
||||
|
||||
<div className="text">You'll also need to install some extra stuff to make PHP work smoothly with your MariaDB database and Apache server. One thing is called php-mysql, which helps PHP talk to databases like MariaDB. Another thing is called libapache2-mod-php, which helps Apache handle PHP files. Don't worry too much about the technical details – just run this command to install everything you need:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt install php libapache2-mod-php php-mysql`} /><br/>
|
||||
|
||||
<div className="text">After the installation finishes, you can check which version of PHP you have by using this command:</div>
|
||||
|
||||
<CodeBlock code={`php -v`} /><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
PHP 7.4.30 (cli) (built: Jul 7 2022 15:51:43) ( NTS )
|
||||
Copyright (c) The PHP Group
|
||||
Zend Engine v3.4.0, Copyright (c) Zend Technologies
|
||||
with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now that your LAMP stack is all set up and ready to go, before you try running any PHP scripts to test it, it's a good idea to create a special place on your server where all your website's files and folders will live. This special place is called an Apache Virtual Host.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Step 4 — Setting Up Your Website's Home on the Server</div>
|
||||
|
||||
<div className="text">When you're working with the Apache web server, you can create something called virtual hosts. Think of them like separate compartments that hold settings for different websites on the same server. This lets you host multiple websites on one server. In this guide, we'll set up a pretend domain called "your_domain." But when you do this for your own website, make sure to use your actual domain name instead of "your_domain.</div><br/>
|
||||
|
||||
<div className="text">By default, Apache shows its content from a folder at /var/www/html and uses the settings in a file called /etc/apache2/sites-available/000-default.conf. Instead of changing the default website settings at /var/www/html, we'll make a new "virtual host" for testing your PHP setup. Virtual hosts let you manage multiple websites on one Apache server. We'll also make a new folder structure inside /var/www for your_domain website. Don't worry, we'll leave /var/www/html as it is, so it will still show the default page if someone tries to access your server without specifying a particular site.</div><br/>
|
||||
|
||||
<div className="text">To start, let's create the main folder for your_domain website:</div>
|
||||
|
||||
<CodeBlock code={`sudo mkdir /var/www/your_domain`} /><br/>
|
||||
|
||||
<div className="text">Next, let's make sure you have control over the directory by giving it to you, the user who's currently using the system. We'll use a special code ($USER) that stands for your username on the computer.</div>
|
||||
|
||||
<CodeBlock code={`sudo chown -R $USER:$USER /var/www/your_domain`} /><br/>
|
||||
|
||||
<div className="text">Now, let's create a new file where we'll put some settings for our website. We'll use a program called nano, which lets us edit files from the command line.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/sites-available/your_domain.conf`} /><br/>
|
||||
|
||||
<div className="text">This will make a new empty file. Now, let's put some basic settings in it for our website. You can replace "your_domain" with your actual domain name.</div>
|
||||
|
||||
<CodeBlock code={`<VirtualHost *:80>
|
||||
ServerName your_domain
|
||||
ServerAlias www.your_domain
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/your_domain
|
||||
ErrorLog $ {APACHE_LOG_DIR}/error.log
|
||||
CustomLog $ {APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've finished adding the configuration, save and close the file. If you're using nano, you can do this by pressing CTRL + X, then Y, and finally ENTER.</div><br/>
|
||||
|
||||
<div className="text">With this VirtualHost setup, you're instructing Apache to display your website, called your_domain, using the directory /var/www/your_domain as the main place for website files. If you want to try Apache without a specific domain name, you can deactivate the ServerName and ServerAlias options by adding a "#" symbol at the start of each line.</div><br/>
|
||||
|
||||
<div className="text">Now, let's activate this virtual host using a command called a2ensite:</div>
|
||||
<CodeBlock code={`sudo a2ensite your_domain`} /><br/>
|
||||
|
||||
<div className="text">if you're not using a custom website address (domain name) and want to make sure your own website shows up correctly, you should turn off Apache's default website. To do this:</div>
|
||||
|
||||
<div className="text"><ol><li>Open your Apache settings</li><li>Look for a default website that comes with Apache.</li><li>Turn it off or disable it.</li></ol></div>
|
||||
|
||||
<div className="text">This helps ensure that your website, instead of the default one, is the one people see when they visit your web server.</div>
|
||||
|
||||
<CodeBlock code={`sudo a2dissite 000-default`} /><br/>
|
||||
|
||||
<div className="text">To check if you've made any mistakes in your configuration file, use the following command: Run this to make sure everything is set up correctly and there are no errors in your settings.</div>
|
||||
|
||||
<CodeBlock code={`sudo apache2ctl configtest`} /><br/>
|
||||
|
||||
<div className="text">Lastly, refresh Apache to apply these updates: This makes sure that any changes you've made to Apache are put into action</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl reload apache2`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a simple PHP test to check if PHP is working on your server: You're going to create a small PHP script to make sure everything is set up correctly.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Step 5 — Checking if PHP is Working on Your Website</div>
|
||||
<div className="text">Now that you've set up a special place to keep all your website stuff, let's make a little test to be sure Apache can handle PHP files.</div><br/>
|
||||
|
||||
<div className="text">Start by making a new file called info.php in the special folder you created for your website:</div>
|
||||
|
||||
<CodeBlock code={`nano /var/www/your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">The file is empty right now. Let's add some text to it. Copy and paste the following lines into the file. These lines are like a secret code that PHP understands:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
phpinfo();
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After adding the text, save and close the file.</div><br/>
|
||||
|
||||
<div className="text">Now, let's check if everything is working. Open your web browser and type in your server's address or IP, followed by the script's name, which is info.php in this case:</div>
|
||||
|
||||
<CodeBlock code={`http://your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">Now, if everything is set up correctly, you should see a simple PHP web page. It's like a default example page that shows PHP is working on your server.</div><br/>
|
||||
|
||||
<img src={debian11} alt="Debain" /> <br/>
|
||||
|
||||
<div className="text">This page tells you things about your server using PHP. It helps find and fix issues and makes sure your settings are working right.</div><br/>
|
||||
|
||||
<div className="text">If you can view this page in your web browser, it means PHP is working just like it should on your server.</div><br/>
|
||||
|
||||
<div className="text">After you've looked at the PHP server details on that page, it's a good idea to delete the file you made. It has some private info about your PHP setup and your server. Just use 'rm' to delete it:</div>
|
||||
|
||||
<CodeBlock code={`sudo rm /var/www/your_domain/info.php`} /><br/>
|
||||
|
||||
<div className="text">If you ever need to see that information again, don't worry. You can make this page again whenever you want.</div><br/>
|
||||
|
||||
<div className="head">Step 6 — Optional: Verifying Database Connection with PHP</div>
|
||||
|
||||
<div className="text">If you're curious about whether PHP can talk to MariaDB (a type of database) and ask it questions, you can do a little test. First, we need to set up a place to test things out, called a 'test database,' and make a special user who can use it. Let's do that first.</div><br/>
|
||||
|
||||
<div className="text">Let's create a database called 'example_database' and a user called 'example_user.' You can use different names if you like.</div><br/>
|
||||
|
||||
<div className="text">To start, open up the MariaDB console using the root account:</div>
|
||||
|
||||
<CodeBlock code={`sudo mariadb`} /><br/>
|
||||
|
||||
<div className="text">To make a new database, just type this command into your MariaDB console:</div>
|
||||
|
||||
<CodeBlock code={`CREATE DATABASE example_database;`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a special user and give them permission to do everything in the database you made.</div><br/>
|
||||
|
||||
<div className="text">Use this command to make a new user called 'example_user.' We're setting their password as 'password' for now, but you should pick a strong password of your own:</div>
|
||||
|
||||
<CodeBlock code={`CREATE USER 'example_user'@'%' IDENTIFIED BY 'password';`} /><br/>
|
||||
|
||||
<div className="text">After creating the user, you'll want to give them access to the 'example_database' database:</div>
|
||||
|
||||
<CodeBlock code={`GRANT ALL ON example_database.* TO 'example_user'@'%';`} /><br/>
|
||||
|
||||
<div className="text">This step ensures that 'example_user' has complete control over the 'example_database' and can't mess with any other databases on your server.</div><br/>
|
||||
|
||||
<div className="text">Now, let's make sure these changes are saved and ready to use in the current session:</div>
|
||||
|
||||
<CodeBlock code={`FLUSH PRIVILEGES;`} /><br/>
|
||||
|
||||
<div className="text">After completing those steps, you can exit the MariaDB shell by:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now, let's check if everything is working by logging into the MariaDB console with the new user details you just created:</div>
|
||||
|
||||
<CodeBlock code={`mariadb -u example_user -p`} /><br/>
|
||||
|
||||
<div className="text">Make sure to use the -p flag when you run this command. It will ask for the password you set when creating the 'example_user' user. After you're logged in, check if you can access the 'example_database' database:</div>
|
||||
|
||||
<CodeBlock code={`SHOW DATABASES;`} /><br/>
|
||||
|
||||
|
||||
<div className="text">This will show you some information on the screen:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+--------------------+
|
||||
| Database |
|
||||
+--------------------+
|
||||
| example_database |
|
||||
| information_schema |
|
||||
+--------------------+
|
||||
2 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a test table called 'todo_list.' In the MariaDB console, type in the following and press Enter:</div>
|
||||
|
||||
<CodeBlock code={`CREATE TABLE example_database.todo_list (
|
||||
item_id INT AUTO_INCREMENT,
|
||||
content VARCHAR(255),
|
||||
PRIMARY KEY(item_id)
|
||||
);
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's add some information to our test table. Type the following command into the MariaDB console a few times, each time with different values, to fill up your test table:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`INSERT INTO example_database.todo_list (content) VALUES ("My first important item");`} /><br/>
|
||||
|
||||
|
||||
<div className="text">To make sure your table has the information you added, type this command:</div>
|
||||
|
||||
<CodeBlock code={`SELECT * FROM example_database.todo_list;`} /><br/>
|
||||
|
||||
<div className="text">This will show you some information on the screen:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
+---------+--------------------------+
|
||||
| item_id | content |
|
||||
+---------+--------------------------+
|
||||
| 1 | My first important item |
|
||||
| 2 | My second important item |
|
||||
| 3 | My third important item |
|
||||
| 4 | and this one more thing |
|
||||
+---------+--------------------------+
|
||||
4 rows in set (0.000 sec)
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've checked that your test table has the right information, you can leave the MariaDB console:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make a PHP script that talks to MariaDB and asks for your data. Open up your custom web folder and create a new PHP file using the text editor you like:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`nano /var/www/your_domain/todo_list.php`} /><br/>
|
||||
|
||||
|
||||
<div className="text">This PHP script connects to the MariaDB database and fetches the information from the 'todo_list' table, showing the results in a list. If something goes wrong with connecting to the database, it will let you know by throwing an exception.</div><br/>
|
||||
|
||||
<div className="text">Copy and paste the following code into your 'todo_list.php' script. Don't forget to change the 'example_user' and 'password' values to your own:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
$user = "example_user";
|
||||
$password = "password";
|
||||
$database = "example_database";
|
||||
$table = "todo_list";
|
||||
|
||||
try {
|
||||
$db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
|
||||
echo "<h2>TODO</h2><ol>";
|
||||
foreach($db->query("SELECT content FROM $table") as $row) {
|
||||
echo "<li>" . $row['content'] . "</li>";
|
||||
}
|
||||
echo "</ol>";
|
||||
} catch (PDOException $e) {
|
||||
print "Error!: " . $e->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After making changes, save and close the file.</div><br/>
|
||||
|
||||
<div className="text">Now, open your web browser and go to your website's address or IP, followed by '/todo_list.php'. This will take you to the page you just created.</div>
|
||||
|
||||
<CodeBlock code={`http://your_domain/todo_list.php`} /><br/>
|
||||
|
||||
<div className="text">This webpage will show the information you added to your test table to anyone who visits it:</div><br/>
|
||||
|
||||
<img src={todo} alt="todo_list" /> <br/>
|
||||
|
||||
<div className="text">This tells you that your PHP setup is all set to talk and work with your MariaDB server.</div><br/>
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">In this guide, you've set up a solid base for hosting PHP websites and apps. You used Apache for the web server and MariaDB for the database. Now, let's make sure your website is secure by setting up HTTPS. You can do this with Let's Encrypt. Also, if you want to manage dependencies and packages in PHP, check out our guide on How to Install and Use Composer.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to secure your website and manage dependencies? Follow our guides to learn how!</strong></div>
|
||||
696
blog/2019-05-29-blog-22.md
Normal file
@ -0,0 +1,696 @@
|
||||
---
|
||||
slug: Easy Deployment with GitOps and Argo CD
|
||||
title: Easy Deployment with GitOps and Argo CD
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import debian from '@site/static/img/debian.png';
|
||||
import argocd from '@site/static/img/argocd_overview.png';
|
||||
import argocd01 from '@site/static/img/argocd_apps.png';
|
||||
import argocd02 from '@site/static/img/argocd_app_drill.png';
|
||||
import argocd03 from '@site/static/img/argocd_mgmt.png';
|
||||
import argocd04 from '@site/static/img/argocd_users.png';
|
||||
import argocd05 from '@site/static/img/argocd_app_of.png';
|
||||
import argocd06 from '@site/static/img/argocd_sk_app.png';
|
||||
import argocd07 from '@site/static/img/argocd_app_of_apps.png';
|
||||
import argocd08 from '@site/static/img/argocd_new_app_.png';
|
||||
import argocd09 from '@site/static/img/argocd_sk_app_overview.png';
|
||||
import argocd10 from '@site/static/img/argocd_sk_app_structure_not_synced.png';
|
||||
import argocd11 from '@site/static/img/argocd_apps_sync_webui.png';
|
||||
import argocd12 from '@site/static/img/argocd_apps_sync_progress.png';
|
||||
import argocd13 from '@site/static/img/argocd_autosync_prune.png';
|
||||
import argocd14 from '@site/static/img/argocd_failed_app.png';
|
||||
import argocd15 from '@site/static/img/argocd_failed_app_investigation.png';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">Argo CD is like a helpful tool for making sure your apps work smoothly on Kubernetes, a system for managing applications. With Argo CD, you keep your app details in a clear and organized way, making it easy to see how everything is set up. It's kind of like using a special folder to keep all your important instructions for your apps.</div><br/>
|
||||
|
||||
<div className="text">Think of Argo CD as your assistant in charge of making sure your apps are running well. It follows a simple rule: store all your app details in a special place called Git, just like you store your documents in a folder on your computer. This way, everything is neat and easy to manage.</div><br/>
|
||||
|
||||
<div className="text">Argo CD works by checking this special folder in Git, and if it finds any changes or updates, it makes sure your apps in Kubernetes stay in sync with these changes. So, you don't have to worry about keeping everything in order – Argo CD does it for you!</div><br/>
|
||||
|
||||
<div className="text">When working with Argo CD, you can use different ways to describe how your applications should run:</div>
|
||||
|
||||
<div className="text"><ol><li>Kustomize Applications: Think of this as adjusting settings for your applications to make them just right.
|
||||
</li><li>Helm Charts: Picture this like a package with all the instructions needed to set up and run your application.</li><li>Ksonnet Applications: It's a way to describe your applications using a special language, making it easier to manage.</li><li>Jsonnet Files: These are files that help define your application's structure and behavior in a clear way.</li><li>Custom Config Management Tool: If you have your own special way of managing configurations, Argo CD can work with that too.</li></ol></div>
|
||||
|
||||
<div className="text">These are just different tools or methods you can use to tell Argo CD how your applications should be set up and run.</div><br/>
|
||||
|
||||
<div className="text">Argo CD relies on special files called custom resource definitions (CRDs) to set up and manage its applications in a Kubernetes cluster. These CRDs act like instructions for Argo CD Among them, the Application CRD is particularly important.In Argo CD, an application is like a set of directions that tells the system where to find your code (in a place called a Git repository) and where to place it in a Kubernetes cluster. This Kubernetes cluster can be the same one where Argo CD is operating, or it might be a different one. In simpler terms, the Application CRD is a set of instructions that Argo CD uses to handle your code and deploy it into a Kubernetes cluster.</div><br/>
|
||||
|
||||
<div className="text">Argo CD works like a supervisor for applications in a Kubernetes system. It keeps an eye on them all the time. It checks if each application is running the way it's supposed to, according to the plan laid out in a special place called a Git repository. If an application is not doing what it's supposed to do, Argo CD notices and marks it as needing fixing. It shows what's wrong and helps you get it back on track, either by fixing it automatically or with your help.</div><br/>
|
||||
|
||||
<div className="text">Argo CD has some cool features! Here are the main ones:</div>
|
||||
|
||||
<div className="text"><ol><li>It can work with different ways of organizing and setting up your applications, like Kustomize, Helm and others.</li><li>You can use it to manage and put your applications in many different clusters.</li><li>It lets you log in using different accounts you might already have, like your GitHub or Microsoft account.</li><li>You can set rules to say who can do what in Argo CD, so it's secure.</li><li>It can check if your applications are healthy and tell you if something's wrong</li><li>If you need to go back to an older version of your application, Argo CD can help you do that.</li><li>It can notice if your applications aren't set up the way they should be and show you what's different.</li><li>Argo CD has a website where you can see what's happening with your applications in real-time</li><li>There's also a special command line tool you can use to make Argo CD do things automatically or work with other tools you use.</li><li>You can connect Argo CD to services like GitHub or GitLab so it knows when there are changes to your code.</li><li>If you need to do something special before or after updating your application, Argo CD can help with that too.</li><li>It can give you data that helps you see how well your applications are doing over time.</li></ol></div><br/>
|
||||
|
||||
<div className="text">In this guide, you'll discover how to:</div>
|
||||
|
||||
<div className="text"><ol><li>Use Helm to set up Argo CD on your DOKS cluster (think of Helm like a wizard that helps you install things).</li><li>Make sure your applications on the Kubernetes cluster always match what's in a special place called a Git repository. It's like making sure everything is in the right place.</li><li>Use Argo CD to put new applications on your cluster and take care of them (like installing and organizing them).</li></ol></div><br/>
|
||||
|
||||
<div className="text">Argo CD helps make sure your applications in the Kubernetes system are running smoothly. It watches over them all the time and ensures two important things:</div>
|
||||
|
||||
<div className="text"><ol><li>Keeping everything organized: It uses Application CRDs to make sure everything in your cluster is in the right place.</li><li>Installing and managing applications: Argo CD sets up and takes care of applications using Helm, a special tool.</li></ol></div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Understanding DOKS and Argo CD: Helm Release Basics</div><br/>
|
||||
|
||||
<div className="text">Let's take a look at how Argo CD handles applications made with Helm and stored in a Git repository.</div>
|
||||
|
||||
<img src={argocd} alt="argocd" /> <br/>
|
||||
|
||||
<div className="head">Prerequisites for Completing the Tutorial</div>
|
||||
|
||||
<div className="text">To finish this guide, make sure you have:</div>
|
||||
|
||||
<div className="text"><ol><li>A working DOKS cluster that you can use. Check the Starter Kit DOKS Setup Guide for details.</li><li>A GitHub account and a place to store your Argo CD and application plans. Make sure to create them in advance.</li><li>A tool called Git for copying the Starter Kit repository.</li><li>Kubectl CLI for talking to your DOKS cluster. Follow the steps here to connect to your cluster using kubectl and doctl.</li><li>Argo CLI for giving commands to Argo CD using your computer's command line.</li><li>Kubeseal, a tool for keeping secrets safe and talking to the Sealed Secrets Controller.</li><li>Helm, a helper tool for managing Argo CD (optional, but a good idea, especially for bigger projects).</li></ol></div><br/>
|
||||
|
||||
|
||||
<div className="head">Getting to Know Argo CD: Basics of Deploying Applications</div>
|
||||
|
||||
<div className="text">Argo CD uses something called an 'Application' to handle how applications are put into action and managed over time. In an Argo CD application plan, you basically tell Argo CD where your application's rules are kept (in a place called Git repository) and where to put your application in a Kubernetes cluster. In simple terms, an Argo CD application is like a connection between your application's rulebook (stored in Git) and the place where it should run (Kubernetes). It's designed to be straightforward and flexible, allowing you to link different rulebooks (from various Git repositories) to different places where your applications should run (Kubernetes clusters)</div><br/>
|
||||
|
||||
<div className="text">One great thing about using applications is that you don't have to install Argo CDs separately on each cluster. Instead, you can set up Argo CD on its own cluster and then manage all your applications from there. This means you can deploy your applications to all your clusters from just one spot. This setup helps prevent any problems with Argo CD if other environments run into issues or need to be shut down. It keeps everything running smoothly and safe.</div><br/>
|
||||
|
||||
<div className="text">Adding to that, you can organize similar applications into a 'Project.' Projects help you group applications together, sort of like putting them in folders. This is handy when different teams are working on various applications. By default, any new application you create belongs to a basic group called the 'default project.' It's like a default folder that is automatically created. The default project doesn't have any strict rules, and you can change some things about it, but you can't remove it.</div><br/>
|
||||
|
||||
<div className="text">The Starter Kit uses the default project to help you quickly get started with Argo CD. Next, you'll discover how to set up an 'Application' for each part of the Starter Kit, using special charts called Helm charts. Argo CD isn't just for Helm charts; you can also use other powerful tools like Kustomize, Ksonnet, Jsonnet, and more. Check out the application sources page for more info on these tools</div><br/>
|
||||
|
||||
<div className="text">Although you can use Argo CD's web interface to set up applications, the Starter Kit sticks to a method called GitOps, which uses YAML files. Each YAML file is like a set of instructions for each application and can be stored in a special place called a Git repository. This setup means you can always recreate your Argo CD setup if you need to start over or move to a different cluster. Plus, you can keep track of every change using Git's history feature. It's a good idea to keep your Argo CD setup files in a separate Git repository from the one you use for your application development. For more tips on this, you can check out the best practices page on the official Argo CD documentation website.</div><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: It's important to know that Argo CD doesn't automatically set up your new applications. When you create a new application in Argo CD, it's like a red flag saying it's not in sync. This means the plan in the Git repository doesn't match where the application is on the Kubernetes cluster. Just creating a new application in Argo CD doesn't make it automatically appear on your cluster. You need to take an extra step to make sure everything matches up and gets deployed to the right place</div><br/>
|
||||
|
||||
<div className="text">To make Argo CDs automatically keep things in sync and clean up unused stuff, you need to set up something called a syncPolicy. This helps Argo CD know when to update or remove things. You can also make Argo CD fix things if someone manually changes something using a tool called kubectl. This way, everything stays on track. If you want to know more about these auto-sync rules, you can check out the official documentation website.</div><br/>
|
||||
|
||||
<div className="text">A standard way of telling Argo CD about an application is by using something called an 'Application CRD.' It's like filling out a form. When your application uses a Git repository, the information you give looks something like this:</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: my-apps
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://github.com/myrepo/my-apps.git
|
||||
targetRevision: HEAD
|
||||
path: apps
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: my-apps
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Let's break down what each part of the setup does:</div>
|
||||
|
||||
<div className="text"><ol><li>spec.project: This tells Argo CD which project to use for the application. In this example, it's set to the default project</li><li>spec.source.repoURL: This is like telling Argo CD where to find the instructions for your application. It's the web address of a place called Git repository.</li><li>spec.source.targetRevision: Think of this like specifying which version of your instructions to use. It can be a branch or tag name.</li><li>spec.source.path: This is the specific folder in the Git repository where your application's instructions are stored.</li><li>spec.destination.server: This is where your application is supposed to go. It's usually the address of your Kubernetes cluster.</li><li>spec.destination.namespace: Think of this like choosing a room for your application in the Kubernetes cluster.</li><li>spec.syncPolicy.automated: This turns on a feature that automatically keeps your application in sync with the instructions in the Git repository.</li><li>spec.syncPolicy.automated.prune: This is like cleaning up. It decides if Argo CD should remove things from your cluster that are no longer in the instructions.</li><li>spec.syncPolicy.automated.selfHeal: If someone manually changes things using a tool called kubectl, this helps Argo CD fix them automatically and keep everything in line.</li></ol></div>
|
||||
|
||||
<div className="text">If you're using Helm charts to manage your applications, you can also use Helm repositories as the source for installing them in your cluster. A typical setup for this looks like the example below. It's similar to using a Git repository, but instead, we're using a Helm chart repository:</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: sealed-secrets
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
chart: sealed-secrets
|
||||
repoURL: https://bitnami-labs.github.io/sealed-secrets
|
||||
targetRevision: 2.4.0
|
||||
helm:
|
||||
releaseName: sealed-secrets
|
||||
values: |
|
||||
replicaCount: 2
|
||||
destination:
|
||||
server: "https://kubernetes.default.svc"
|
||||
namespace: kubeseal
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Let's break down what each part of the setup does:</div>
|
||||
|
||||
<div className="text"><ol><li>spec.source.chart: This is the Helm chart that your application will use as its source. Think of it as the blueprint for your application.</li><li>spec.source.repoURL: This is the web address where the Helm chart is stored, kind of like where you'd find it in a store.</li><li>spec.source.targetRevision: This specifies which version of the Helm chart to use. It's like picking a specific edition of a book to read.</li><li>spec.source.helm.releaseName: This is the name that Argo CD will give to the application when it's installed on your Kubernetes cluster. It's like giving your application a name.</li><li>spec.source.helm.values: These are extra settings you can give to the Helm chart. It's like telling the chart how you want things to be set up.</li><li>spec.destination.server: This is where your application will end up—in your Kubernetes cluster. It's like the destination address.</li><li>spec.destination.namespace: This is like choosing a room for your application in the Kubernetes cluster. It's where it will live.</li></ol></div>
|
||||
|
||||
<div className="text">If you want to learn more about how Argo CD works, you can check out the official documentation website. After that, we'll explore different ways to install Argo CD on your Kubernetes cluster:</div><br/>
|
||||
|
||||
<div className="text">Setting Up Argo CD on Your Kubernetes Cluster</div>
|
||||
<div className="text">You can install Argo CD in two ways, either using kubectl or Helm:</div>
|
||||
|
||||
<div className="text"><ol><li>Using kubectl and a manifest file: This is the simplest way to install Argo CD. It's a good choice if you're new to Helm installations and just want to get started quickly.</li><li>Using Helm: This method gives you more control over how Argo CD is set up and managed. It's recommended for more advanced setups, especially if you're using Argo CD in a production environment or need high availability."</li></ol></div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Choosing How to Use Argo CD: Simple Options Explained</div>
|
||||
|
||||
<div className="text"><strong>Option 1: Multi-Tenant mode</strong></div>
|
||||
<div className="text">This mode is like having a big apartment building where different teams live. The building is managed by a team that takes care of everything. Each team can use Argo CD through a website, a special program called argocd CLI, or by talking to the building manager (API server).</div><br/>
|
||||
|
||||
<div className="text"><strong>Option 2: Core only mode</strong></div>
|
||||
<div className="text">This mode is like having a basic version of something, like a car without all the fancy extras. It doesn't have a fancy screen or special ways to log in. It's just the basic stuff you need to get going.</div><br/>
|
||||
|
||||
<div className="text">Starter Kit recommends using Multi-Tenant and High Availability modes to set up Argo CD on your DOKS cluster. This gives you a reliable setup and access to all the features, including a user-friendly interface. For more details, check out the installation guide.</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Installing Argo CD with Kubectl is a two-step process:</div>
|
||||
|
||||
<div className="text"><ol><li>Create a special place for Argo CD.</li><li>Use kubectl to bring Argo CD to life in that place.</li></ol></div><br/>
|
||||
|
||||
<div className="text">Please follow these steps in order:</div>
|
||||
|
||||
<CodeBlock code={`kubectl create namespace argocd
|
||||
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/ha/install.yaml
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's see if everything is installed correctly. First, make sure all the parts of Argo CD are working well:</div>
|
||||
|
||||
<CodeBlock code={`kubectl get deployments -n argocd`} /><br/>
|
||||
|
||||
<div className="text">The result you see should be like this (look at the 'READY' column - all the Pods should show as 'running'):</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME READY UP-TO-DATE AVAILABLE AGE
|
||||
argocd-applicationset-controller 1/1 1 1 51s
|
||||
argocd-dex-server 1/1 1 1 50s
|
||||
argocd-notifications-controller 1/1 1 1 50s
|
||||
argocd-redis-ha-haproxy 3/3 3 3 50s
|
||||
argocd-repo-server 2/2 2 2 49s
|
||||
argocd-server 2/2 2 2 49s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">For High Availability mode, Argo CD server needs to have at least 2 copies running. If any parts aren't working, check the Kubernetes events and logs for those specific parts.</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Using Helm to Install Argo CD</div>
|
||||
|
||||
<div className="text">To use this method, you need to have Helm installed on your computer. Starter Kit gives you a pre-made settings file for Helm. This file helps you get started easily and installs Argo CD in High Availability mode (without autoscaling).</div><br/>
|
||||
|
||||
<div className="text">Here's what you need to do for the Helm-based installation:</div>
|
||||
|
||||
<div className="text">1. If you haven't already, download the Starter Kit folder and open it on your computer.</div>
|
||||
<CodeBlock code={`git clone https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers.git
|
||||
cd Kubernetes-Starter-Kit-Developers
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">2. Now, let's add the place where Argo CD is kept using Helm:</div>
|
||||
<CodeBlock code={`helm repo add argo https://argoproj.github.io/argo-helm
|
||||
helm repo update argo
|
||||
`} /><br/>
|
||||
|
||||
|
||||
|
||||
<div className="text">3. Next, let's look for the different options we have to install Argo CD in the Helm repository: </div>
|
||||
|
||||
<CodeBlock code={`helm search repo argo`} /><br/>
|
||||
|
||||
<div className="text">The result you see should look something like this:</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME CHART VERSION APP VERSION DESCRIPTION
|
||||
argo/argo 1.0.0 v2.12.5 A Helm chart for Argo Workflows
|
||||
argo/argo-cd 4.9.4 v2.4.0 A Helm chart for Argo CD, a declarative, GitOps...
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">4. Now, let's open and look at the Argo CD settings file provided in the Starter Kit folder. You can use any text editor you like, but it's best to use one that supports YAML linting. For example, you can use VS Code:</div>
|
||||
|
||||
<CodeBlock code={`code 14-continuous-delivery-using-gitops/assets/manifests/argocd/argocd-values-v4.9.4.yaml`} /><br/>
|
||||
|
||||
<div className="text">5. At last, let's put Argo CD into action on your DOKS cluster:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`HELM_CHART_VERSION="4.9.4"
|
||||
helm install argocd argo/argo-cd --version "$ {HELM_CHART_VERSION}" \
|
||||
--namespace argocd \
|
||||
--create-namespace \
|
||||
-f "14-continuous-delivery-using-gitops/assets/manifests/argocd/argocd-values-v$ {HELM_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: We're using a particular version for the Helm chart – in this case, it's version 4.9.4, which corresponds to version 2.4.0 of the application. This is a good habit because it ensures that we get the expected results and makes it easier to keep track of changes using Git</div><br/>
|
||||
|
||||
<div className="text">Now, let's see if the installation using Helm was successful:</div>
|
||||
|
||||
<CodeBlock code={`helm ls -n argocd`} /><br/>
|
||||
|
||||
<div className="text">The result you see should be something like this (check the 'STATUS' column, it should say 'deployed'):</div>
|
||||
|
||||
<CodeBlock code={`NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
argocd argocd 1 2022-03-23 11:22:48.486199 +0200 EET deployed argo-cd-4.9.4 v2.4.0
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">At last, let's make sure that Argo CD is deployed and ready to go. We'll check its status:</div>
|
||||
|
||||
<CodeBlock code={`kubectl get deployments -n argocd`} /><br/>
|
||||
|
||||
<div className="text">The result you'll see should look something like this (look at the 'READY' column - all the Pods should show as 'running'):</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME READY UP-TO-DATE AVAILABLE AGE
|
||||
argocd-applicationset-controller 1/1 1 1 2m9s
|
||||
argocd-dex-server 1/1 1 1 2m9s
|
||||
argocd-notifications-controller 1/1 1 1 2m9s
|
||||
argocd-redis-ha-haproxy 3/3 3 3 2m9s
|
||||
argocd-repo-server 2/2 2 2 2m9s
|
||||
argocd-server 2/2 2 2 2m9s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To ensure High Availability mode, Argo CD server needs to have at least 2 copies running. If any parts aren't working, please check the Kubernetes events and logs for the specific parts that are having issues.</div><br/>
|
||||
|
||||
|
||||
<div className="text">If you want to learn more about the Argo CD Helm chart, you can check out the community-maintained repository.</div><br/>
|
||||
|
||||
<div className="text">Next, we'll show you how to use the graphical user interface provided by Argo CD to access and explore its main features.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Getting Started with the Argo CD Web Interface</div>
|
||||
|
||||
<div className="text">Argo CD comes with a cool feature - the web interface. This helps you do important things like managing applications and checking how they're doing. You can create applications and do different tasks easily. Plus, you can see the status of each application, look at events, and check logs. Argo CD also gives you a visual picture of all the parts each application is using in Kubernetes, like pods and replicasets.</div><br/>
|
||||
|
||||
<div className="text">To use the web interface, you need to run a command in your terminal. This command helps connect your computer to the Argo CD service. Just type it in your terminal!</div>
|
||||
|
||||
<CodeBlock code={`kubectl port-forward svc/argocd-server -n argocd 8080:443`} /><br/>
|
||||
|
||||
<div className="text">Now, go to your web browser and type localhost:8080 in the address bar (don't worry if you see a certificate warning). You'll see the Argo CD login page. The default admin username is 'admin,' and the password was created when you installed Argo CD. You can find it by running the command below:</div>
|
||||
|
||||
<CodeBlock code={`kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo`} /><br/>
|
||||
|
||||
<div className="text">After logging in, you'll see the applications dashboard. Here, you can see, make, or handle applications using the user interface. You can also use a YAML editor. Plus, you can sync or refresh things as needed:</div><br/>
|
||||
|
||||
<img src={argocd01} alt="argocd_apps" /> <br/><br/>
|
||||
|
||||
<div className="text">If you click on any application, you'll see a visual picture of all the things it's using.</div><br/>
|
||||
|
||||
<img src={argocd02} alt="argocd_apps_drill" /> <br/>
|
||||
|
||||
<div className="text">In the next part, you can handle your application projects, repositories, and clusters:</div><br/>
|
||||
|
||||
<img src={argocd03} alt="argocd_mgmt" /> <br/>
|
||||
|
||||
<div className="text">At last, the user info section tells you about the users and lets you update the administrator password:</div><br/>
|
||||
|
||||
|
||||
<img src={argocd04} alt="argocd_users" /> <br/>
|
||||
|
||||
<div className="text">Feel free to explore every part and detail to discover all the cool features. Next, we'll show you how to use the command line tool called 'argocd.</div><br/>
|
||||
|
||||
<div className="head">Exploring Argo CD Through the Command Line</div>
|
||||
|
||||
<div className="text">Argo CD offers the same features through both the web interface and the command line tool (CLI). To use the CLI, just open a new terminal window and type 'argocd' without anything else. It will show you all the commands and options you can use.</div>
|
||||
|
||||
<CodeBlock code={`argocd
|
||||
Usage:
|
||||
argocd [flags]
|
||||
argocd [command]
|
||||
|
||||
Available Commands:
|
||||
account Manage account settings
|
||||
admin Contains a set of commands useful for Argo CD administrators and requires direct Kubernetes access
|
||||
app Manage applications
|
||||
cert Manage repository certificates and SSH known hosts entries
|
||||
cluster Manage cluster credentials
|
||||
completion output shell completion code for the specified shell (bash or zsh)
|
||||
context Switch between contexts
|
||||
gpg Manage GPG keys used for signature verification
|
||||
help Help about any command
|
||||
...
|
||||
|
||||
If you ever want help with a command or sub-command, just type 'argocd <command/subcommand> --help'. For instance, if you're curious about the options for the 'app' command:
|
||||
|
||||
argocd app --help
|
||||
|
||||
The result you see will be something like this:
|
||||
|
||||
Manage Applications
|
||||
Usage:
|
||||
argocd app [flags]
|
||||
argocd app [command]
|
||||
|
||||
Examples:
|
||||
# List all the applications.
|
||||
argocd app list
|
||||
|
||||
# Get the details of a application
|
||||
argocd app get my-app
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Take some time to check out other commands and options to see what else you can do. Next up, we'll show you how to set up your first Argo CD application, which will deploy all the components from the Starter Kit automatically:</div><br/>
|
||||
|
||||
<div className="head">Initializing Your First Argo CD Application</div>
|
||||
<div className="text">When Argo CD is freshly installed, it doesn't know where to find your applications or which Git repositories to use for getting application details. To help it out, we do a one-time setup called 'bootstrapping.' You can do all the steps in this section using either the argocd command line or the graphical user interface.</div><br/>
|
||||
|
||||
<div className="text">There are different ways to set up your cluster (like using scripts), but many Argo CD users follow the 'app of apps' method. This means you begin by creating a main application using the command line or the web interface. This main application then helps set up and start all the other applications in your Kubernetes cluster.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Organizing Your Git Repository Structure</div>
|
||||
|
||||
<div className="text">Before we start, let's make sure your Git repository is organized in a specific way. In the example below, you'll see how to create a structure for your Git repository that looks like this:</div>
|
||||
|
||||
<CodeBlock code={`clusters
|
||||
└── dev
|
||||
└── helm
|
||||
├── cert-manager-v1.8.0.yaml
|
||||
├── nginx-v4.1.3.yaml
|
||||
├── prometheus-stack-v35.5.1.yaml
|
||||
├── sealed-secrets-v2.4.0.yaml
|
||||
└── velero-v2.29.7.yaml
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, open your terminal and do the following steps to set up the structure for your Git repository:</div>
|
||||
|
||||
<div className="text">1. First, copy your git repository used for testing Argo CD (make sure to replace the <> placeholders accordingly):</div>
|
||||
<CodeBlock code={`git clone <YOUR_ARGOCD_GIT_REPOSITORY_ADDRESS>`} /><br/>
|
||||
|
||||
<div className="text">2. Then, go into the folder you just copied and create the structure of folders like this (make sure to replace the <> placeholders accordingly):</div>
|
||||
|
||||
<CodeBlock code={`cd <YOUR_GIT_REPO_LOCAL_COPY_DIRECTORY>mkdir -p clusters/dev/helm`} /><br/>
|
||||
|
||||
<div className="text">3. Now, take the application instructions given for each part in the Starter Kit folder (you can also check how they are organized) and copy them:</div><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <CodeBlock code={`CERT_MANAGER_CHART_VERSION="1.8.0"
|
||||
NGINX_CHART_VERSION="4.1.3"
|
||||
PROMETHEUS_CHART_VERSION="35.5.1"
|
||||
SEALED_SECRETS_CHART_VERSION="2.4.0"
|
||||
VELERO_CHART_VERSION="2.29.7"
|
||||
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/argocd/applications/helm/cert-manager-v${CERT_MANAGER_CHART_VERSION}.yaml" > "clusters/dev/helm/cert-manager-v${CERT_MANAGER_CHART_VERSION}.yaml"
|
||||
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/argocd/applications/helm/nginx-v${NGINX_CHART_VERSION}.yaml" > "clusters/dev/helm/nginx-v${NGINX_CHART_VERSION}.yaml"
|
||||
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/argocd/applications/helm/prometheus-stack-v${PROMETHEUS_CHART_VERSION}.yaml" > "clusters/dev/helm/prometheus-stack-v${PROMETHEUS_CHART_VERSION}.yaml"
|
||||
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/argocd/applications/helm/sealed-secrets-v${SEALED_SECRETS_CHART_VERSION}.yaml" > "clusters/dev/helm/sealed-secrets-v${SEALED_SECRETS_CHART_VERSION}.yaml"
|
||||
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/argocd/applications/helm/velero-v${VELERO_CHART_VERSION}.yaml" > "clusters/dev/helm/velero-v${VELERO_CHART_VERSION}.yaml"
|
||||
`} /> -->
|
||||
|
||||
<div className="text">4. Once you're done, save your changes and push them to the main repository.<br/><br/> Now, it's time to set up the main application, and Argo CD will take care of bringing all Starter Kit applications to your DOKS cluster automatically.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Applying the App of Apps Pattern with Argo CD CLI</div>
|
||||
<div className="text">In this part, you'll find out how to use the argocdCLI to set up and work with the "app of apps" pattern. This lets you deploy all the components of the Starter Kit on your DOKS cluster. Here's a simple picture to show you what we mean:</div><br/>
|
||||
|
||||
|
||||
<img src={argocd05} alt="argocd_app_of" /> <br/>
|
||||
|
||||
<div className="text">To start, open a new terminal window and use a command to connect your local machine to the Argo CD main server.</div>
|
||||
|
||||
<CodeBlock code={`kubectl port-forward svc/argocd-server -n argocd 8080:443`} /><br/>
|
||||
<div className="text">In another terminal window, you have to make sure the argocd CLI can talk to the Argo CD API server. To do this, you need to log in and verify the argocd client with your Argo CD server.</div>
|
||||
|
||||
<CodeBlock code={`ADMIN_USER="admin"
|
||||
ADMIN_PASSWD="$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)"
|
||||
argocd login localhost:8080 --username $ADMIN_USER --password $ADMIN_PASSWD --insecure
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The result you'll see resembles something like this:</div>
|
||||
|
||||
<CodeBlock code={`Output'admin:login' logged in successfully
|
||||
Context 'localhost:8080' updated
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, enter the following command to create the main application for the Starter Kit apps. Be sure to replace the placeholders like <> with the correct information:</div>
|
||||
|
||||
<CodeBlock code={`argocd app create starter-kit-apps \
|
||||
--dest-namespace argocd \
|
||||
--dest-server https://kubernetes.default.svc \
|
||||
--repo https://github.com/<YOUR_GITHUB_USERNAME>/<YOUR_ARGOCD_GITHUB_REPO_NAME>.git \
|
||||
--path clusters/dev/helm
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">That command you just used sets up something called an "Argo CD application." Here's what it does:</div>
|
||||
|
||||
<div className="text"><ol><li>Creates an Application: It makes a new application in Argo CD called "starter-kit-apps" in the argocd namespace.</li><li>Configures it to Work with Our Cluster: It's set to work with the same place where Argo CD is running, which is our local Kubernetes system. This is because of the --dest-server part, which points to our local Kubernetes system at <a href="https://kubernetes.default.svc">https://kubernetes.default.svc</a> .</li><li>Connects to a GitHub Repository: It connects to a GitHub repository specified in the --repo part. This is where it gets all the information it needs to set up our cluster.</li><li>Applies the Manifests: It takes all the application files in the clusters/dev/helm directory (--path argument) and puts them into action on our cluster.</li></ol></div>
|
||||
|
||||
<div className="text">Now, you have to make sure everything in the "starter-kit-apps" application is up to date. Argo CD doesn't do this automatically; you need to tell it to sync.</div>
|
||||
|
||||
<CodeBlock code={`argocd app sync starter-kit-apps`} /><br/>
|
||||
|
||||
<div className="text">The result you'll see will look something like this:</div>
|
||||
|
||||
<CodeBlock code={`OutputTIMESTAMP GROUP KIND NAMESPACE NAME STATUS HEALTH ...
|
||||
2022-03-23T17:39:38+02:00 argoproj.io Application argocd sealed-secrets-controller OutOfSync Missing ...
|
||||
2022-03-23T17:39:38+02:00 argoproj.io Application argocd velero OutOfSync Missing ...
|
||||
2022-03-23T17:39:38+02:00 argoproj.io Application argocd ingress-nginx OutOfSync Missing ...
|
||||
...
|
||||
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
|
||||
argoproj.io Application argocd sealed-secrets-controller Synced application.argoproj.io/sealed-secrets-controller created
|
||||
argoproj.io Application argocd ingress-nginx Synced application.argoproj.io/ingress-nginx created
|
||||
argoproj.io Application argocd kube-prometheus-stack Synced application.argoproj.io/kube-prometheus-stack created
|
||||
argoproj.io Application argocd velero Synced application.argoproj.io/velero created
|
||||
argoproj.io Application argocd cert-manager Synced application.argoproj.io/cert-manager created
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Once the previous command is done, check if a new application has appeared on your Argo CD server dashboard. Open a web browser and go to http://localhost:8080. Click on the "Applications" tab, and select the tile named "starter-kit-apps." You'll notice something called the "app of apps" pattern by looking at the composition graph.</div><br/>
|
||||
|
||||
<img src={argocd06} alt="argocd_app_of" /> <br/>
|
||||
|
||||
<div className="text">You can also take a look at the new applications using the command line:</div>
|
||||
|
||||
<CodeBlock code={`argocd app list`} /><br/>
|
||||
|
||||
<div className="text">The information you'll see in the terminal will be something like this:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY ...
|
||||
ingress-nginx https://kubernetes.default.svc ingress-nginx default OutOfSync Missing Auto-Prune ...
|
||||
cert-manager https://kubernetes.default.svc cert-manager default OutOfSync Missing Auto-Prune ...
|
||||
kube-prometheus-stack https://kubernetes.default.svc monitoring default OutOfSync Missing Auto-Prune ...
|
||||
sealed-secrets-controller https://kubernetes.default.svc sealed-secrets default OutOfSync Missing Auto-Prune ...
|
||||
starter-kit-apps https://kubernetes.default.svc argocd default Synced Healthy <none> ...
|
||||
velero https://kubernetes.default.svc velero default OutOfSync Missing Auto-Prune ...
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">The main application "starter-kit-apps" will show as in-sync, but the smaller applications inside it will be marked as out of sync. Now, you have two options to get everything in line: either use the web interface or the command line.</div>
|
||||
|
||||
<CodeBlock code={`argocd app sync -l argocd.argoproj.io/instance=starter-kit-apps`} /><br/>.
|
||||
|
||||
<div className="text">The sync process might take some time, possibly 5-10 minutes, especially if there are many complex Kubernetes objects across all applications.</div> <br/>
|
||||
|
||||
<div className="text">Once some time has passed, check the list of applications again:</div>
|
||||
|
||||
<CodeBlock code={`argocd app list`} /><br/>
|
||||
|
||||
<div className="text">The result you'll see will look like this (make sure to notice that all applications are now in sync):</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS ...
|
||||
ingress-nginx https://kubernetes.default.svc ingress-nginx default Synced Healthy Auto-Prune <none> ...
|
||||
cert-manager https://kubernetes.default.svc cert-manager default Synced Healthy Auto-Prune <none> ...
|
||||
kube-prometheus-stack https://kubernetes.default.svc monitoring default Synced Healthy Auto-Prune <none> ...
|
||||
sealed-secrets-controller https://kubernetes.default.svc sealed-secrets default Synced Healthy Auto-Prune <none> ...
|
||||
starter-kit-apps https://kubernetes.default.svc argocd default Synced Healthy <none> <none> ...
|
||||
velero https://kubernetes.default.svc velero default OutOfSync Missing Auto-Prune SyncError …
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The Velero application deployment will intentionally fail and remain in the SyncError state. This is a learning opportunity for you to practice diagnosing application issues in Argo CD. Check the Hints section below for guidance on troubleshooting. Setting up the parent application is a one-time task. In the future, whenever there are changes in the Git repository for each application, Argo CD will detect the differences and apply the necessary updates. Argo CD typically checks for changes in your Git repository every 3 minutes by default, using a polling method. Alternatively, you can configure Argo CD to use Git webhooks for faster updates. Refer to the official documentation to learn how to set up and configure Argo CD with Git webhooks.</div><br/>
|
||||
|
||||
<div className="hint"><strong>Hint: </strong>If you want to make sure the main application is always kept up to date automatically (and enable features like self-healing and automatic pruning), you can use this command. Just make sure to replace the placeholders like <> with the right information:</div>
|
||||
|
||||
<CodeBlock code={`argocd app create starter-kit-apps \
|
||||
--dest-namespace argocd \
|
||||
--dest-server https://kubernetes.default.svc \
|
||||
-repo https://github.com/<YOUR_GITHUB_USERNAME>/<YOUR_ARGOCD_GITHUB_REPO_NAME>.git \
|
||||
--path clusters/dev/helm \
|
||||
--sync-policy automated \
|
||||
--auto-prune \
|
||||
--self-heal
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If something goes wrong during synchronization, you can check the Kubernetes events for that specific application. Just use the command argocd app get <application_name> to take a look.</div>
|
||||
|
||||
<CodeBlock code={`argocd app get velero`} /><br/>
|
||||
|
||||
<div className="text">The information you'll see in the terminal will look something like this:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`Output Name: velero
|
||||
Project: default
|
||||
Server: https://kubernetes.default.svc
|
||||
Namespace: velero
|
||||
URL: https://argocd.example.com/applications/velero
|
||||
Repo: https://vmware-tanzu.github.io/helm-charts
|
||||
Target: 2.27.3
|
||||
Path:
|
||||
SyncWindow: Sync Allowed
|
||||
Sync Policy: Automated (Prune)
|
||||
Sync Status: OutOfSync from 2.27.3
|
||||
Health Status: Missing
|
||||
CONDITION MESSAGE LAST TRANSITION
|
||||
SyncError Failed sync attempt to 2.27.3: one or more objects failed to apply (dry run) (retried 5 times). 2022-03-24 12:14:21 +0200 EET
|
||||
GROUP KIND NAMESPACE NAME STATUS HEALTH HOOK MESSAGE
|
||||
velero.io VolumeSnapshotLocation velero default Failed SyncFailed PostSync error validating data: ValidationError(VolumeSnapshotLocation.spec): missing required field "provider" in io.velero.v1.VolumeSnapshotLocation.spec
|
||||
velero.io BackupStorageLocation velero default Failed SyncFailed PostSync error validating data: [ValidationError(BackupStorageLocation.spec.objectStorage): missing required field "bucket" in io.velero.v1.BackupStorageLocation.spec.objectStorage, ValidationError(BackupStorageLocation.spec): missing required field "provider" in io.velero.v1.BackupStorageLocation.spec]
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's explore how to use the "app of apps" pattern and do the same tasks using the Argo CD graphical user interface.</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Deploying Applications with Argo CD Web Interface</div>
|
||||
|
||||
<div className="text">In this part, you'll discover how to use the Argo CD web interface to set up and utilize the "app of apps" pattern for deploying all Starter Kit components on your DOKS cluster. Take a look at the picture below to understand the main idea:</div>
|
||||
|
||||
<img src={argocd07} alt="argocd_app_of" /> <br/>
|
||||
|
||||
<div className="text">As you can see in the diagram above, starting a new application through the web interface is quite similar to using the command line. The only distinction is that you'll move between various panels or windows and use simple point-and-click actions. Argo CD will handle the technical details by creating the necessary application configurations and implementing changes on your Kubernetes cluster.</div>
|
||||
|
||||
<div className="text">Begin by opening a web browser and logging in to the Argo CD web console. The default username is "admin," and you can find the default password in:</div>
|
||||
|
||||
<CodeBlock code={`kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo`} /><br/>
|
||||
|
||||
<div className="text">After you log in, you'll find yourself on the applications dashboard page, which might be empty if it's a new installation. To start creating a new application, click on the "Create Application" button. A new panel will appear, prompting you for details about the application:</div>
|
||||
|
||||
|
||||
<img src={argocd08} alt="argocd_new_app_" /> <br/>
|
||||
|
||||
|
||||
<div className="text">Make sure to complete each field with the following information:</div>
|
||||
|
||||
<div className="text"><ol><li>Application Name: Choose a name for the new application (like "starter-kit-apps").</li><li>Project: For your first time with Argo CD, you can stick with the default project.</li><li>Sync Policy and Sync Options: This configures how syncing works, like whether it's manual or automatic, and the details of retries and intervals.</li><li>Source Repository URL: Enter the URL of your GitHub repository. It should look something like https://github.com/<YOUR_GITHUB_USERNAME>/<YOUR_ARGOCD_GITHUB_REPO_NAME>.git.</li><li>Source Path: Specify the directory path in your GitHub repository where the application manifests are stored. For example, clusters/dev/helm.</li><li>Destination Cluster URL: Provide the URL of the target Kubernetes cluster. For the local cluster where Argo CD is running, use https://kubernetes.default.svc.</li><li>Destination Namespace: Specify the Kubernetes namespace for Argo CD applications. Usually, it's set to argocd.</li></ol></div>
|
||||
|
||||
<div className="text">Once you've entered all the application details, simply click on the "Create" button at the top. This will add a new tile for your application on the dashboard page.</div><br/>
|
||||
|
||||
<img src={argocd09} alt="argocd_sk_app_overview" /> <br/>
|
||||
|
||||
<div className="text">Clicking on the application tile allows you to see the "app of apps" pattern in action. Check out the composition graph to understand how different components are interconnected.</div><br/>
|
||||
|
||||
<img src={argocd10} alt="argocd_sk_app_structure_not_synced" /> <br/>
|
||||
|
||||
<div className="text">Observing the picture above, you'll see that all applications are marked as "OutOfSync." To get everything in sync, the next step is to initiate a sync operation on the main application. Click on the "Sync" button on the parent application tile. A new panel will appear on the right side, indicating that all child applications are selected for synchronization.</div><br/>
|
||||
|
||||
<img src={argocd11} alt="argocd_apps_sync_webui" /> <br/>
|
||||
|
||||
<div className="text">Keep the default settings as they are, then click on the "Synchronize" button at the top. Watch as Argo CD initiates the sync operation, cascading it to all applications in the hierarchy.</div><br/>
|
||||
|
||||
|
||||
<img src={argocd12} alt="argocd_apps_sync_progress" /> <br/>
|
||||
|
||||
<div className="text">The deployment of the Velero application intentionally fails and remains in the "SyncError" state. This is designed as a learning opportunity for you to become familiar with diagnosing application issues in Argo CD. Check the Hints section below for guidance on troubleshooting.</div><br/>
|
||||
|
||||
<div className="text">Assuming everything goes smoothly, you should see all applications with a green border, indicating a healthy and synced status. The initial setup is a one-time task. For any subsequent changes in your Git repository, Argo CD will identify the differences and apply the necessary updates. Argo CD typically checks for changes using a polling mechanism every 3 minutes. If you prefer, you can explore using Git webhooks for more efficient updates. Refer to the official documentation for guidance on setting up and configuring Git webhooks with Argo CD</div><br/>
|
||||
|
||||
<div className="text">If you want, you can set the parent application to sync automatically by choosing "Automatic" from the SYNC POLICY dropdown. To enable self-healing and automatic pruning, simply check the boxes for "PRUNE RESOURCES" and "SELF HEAL.</div><br/>
|
||||
|
||||
<img src={argocd13} alt="argocd_autosync_prune" /> <br/>
|
||||
|
||||
<div className="text">If there are any issues during synchronization, you can check the Kubernetes events for the specific application. Using the web interface, go to the tile of the application that is facing problems:</div><br/>
|
||||
|
||||
<img src={argocd14} alt="argocd_failed_app" /> <br/>
|
||||
|
||||
<div className="text">Next, click on the red-colored "Sync failed" message link in the "LAST SYNC RESULT" section of the application page header. A new panel will appear, providing valuable information about why the sync operation encountered issues.</div><br/>
|
||||
|
||||
<img src={argocd15} alt="argocd_failed_app_investigation" /> <br/>
|
||||
|
||||
<div className="text">In the upcoming section, you'll discover how to handle multiple applications simultaneously using a single CRD, known as the ApplicationSet.</div><br/>
|
||||
|
||||
<div className="head">Managing Multiple Applications with Argo CD Application Sets</div>
|
||||
|
||||
|
||||
<div className="text">Argo CD Application Sets is a robust feature that brings automation to managing multiple applications. The ApplicationSet Controller, part of the Argo CD project, introduces automation through templated definitions. This feature is especially useful to eliminate redundancy in your application configurations, following the DRY (Don't Repeat Yourself) principle.</div><br/>
|
||||
|
||||
<div className="text">The ApplicationSet controller comes bundled with Argo CD, residing in the same namespace. It works by automatically creating Argo CD Applications using the information provided in a new ApplicationSet Custom Resource (CR).</div><br/>
|
||||
|
||||
<div className="note">From Argo CD version 2.3.x onward, there's no need for a separate installation of the ApplicationSet Controller. It's automatically included in the main Argo CD installation. In the Starter Kit, we're using a version equal to or greater than 2.3.1, so you don't have to make any additional installations or changes. Everything is ready to go.</div><br/>
|
||||
|
||||
<div className="text">Think of an ApplicationSet as a powerful tool that operates with a list of values and a template. This template gets filled in with the values from the list, creating a sequence of applications. In simple terms, you create one ApplicationSet configuration, and it automatically generates as many Argo CD Applications as you need, using the specified values. So, instead of handling multiple application manifests, you manage everything with a single manifest - the ApplicationSet.</div><br/>
|
||||
|
||||
<div className="text">ApplicationSets make it easy to handle setups involving multiple clusters and environments by using templates with parameters. Alongside List Generators, there are other types of generators:</div>
|
||||
|
||||
<div className="text"><ol><li>Cluster generator: It uses clusters defined in Argo CD to template applications.</li><li>Git generator: This one uses files/directories from a Git repository to template applications.</li></ol></div>
|
||||
|
||||
<div className="text">A typical ApplicationSet Custom Resource Definition (CRD) using a List Generator looks like this:</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: argoproj.io/v1alpha1
|
||||
kind: ApplicationSet
|
||||
metadata:
|
||||
name: my-app
|
||||
spec:
|
||||
generators:
|
||||
- list:
|
||||
elements:
|
||||
- cluster: dev
|
||||
url: https://kubernetes.dev.svc
|
||||
- cluster: qa
|
||||
url: https://kubernetes.qa.svc
|
||||
- cluster: prod
|
||||
url: https://kubernetes.prod.svc
|
||||
template:
|
||||
metadata:
|
||||
name: '{{cluster}}-app'
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://github.com/myrepo/my-applicationset.git
|
||||
targetRevision: HEAD
|
||||
path: clusters/{{cluster}}/my-apps
|
||||
destination:
|
||||
server: '{{url}}'
|
||||
namespace: argocd
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Applying the above ApplicationSet to your Kubernetes cluster will create three Argo CD applications. For instance, the application for the development environment is created as shown below:</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: dev-app
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://github.com/myrepo/my-applicationset.git
|
||||
targetRevision: HEAD
|
||||
path: clusters/dev/my-apps
|
||||
destination:
|
||||
server: https://kubernetes.dev.svc
|
||||
namespace: argocd
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Template engines are versatile tools that provide many capabilities. You can explore more about this feature by visiting the main ApplicationSet documentation website.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Removing Argo CD Applications</div>
|
||||
<div className="text">To remove applications managed by Argo CD, you simply delete the corresponding manifest from your Git repository source. If you've used the app of apps pattern, deleting the parent app (via CLI or web interface) will automatically delete all child applications.</div><br/>
|
||||
|
||||
<div className="text">Here's how to delete the starter-kit-apps parent application (and its child apps) using the argocd CLI:</div>
|
||||
|
||||
<CodeBlock code={`argocd app delete starter-kit-apps`} /><br/>
|
||||
|
||||
<div className="text">If you want to make sure that the child apps and all their resources are deleted along with the parent app, you need to add the right finalizer to your Application definition.</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: cert-manager
|
||||
namespace: argocd
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
spec:
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Look for the added finalizers field in the metadata section of the custom resource manifest. When you delete the application, the linked Kubernetes objects will also be deleted.</div><br/>
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
<div className="text">In this guide, you mastered the basics of automating deployments with GitOps using Argo CD. You set up Argo CD applications to handle Helm releases automatically and deployed all the components of the Starter Kit in a GitOps manner. You also learned how to kickstart new Argo CD applications using the app of apps pattern and simplify application creation with ApplicationSets.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to explore the resource usage of the Starter Kit? Dive into the Starter Kit Resource Usage chapter to learn more!</strong></div>
|
||||
|
||||
|
||||
202
blog/2019-05-29-blog-23.md
Normal file
@ -0,0 +1,202 @@
|
||||
---
|
||||
slug: Improving Kubernetes Deployments with Tekton, Argo CD and Knative for Serverless Apps
|
||||
title: Improving Kubernetes Deployments with Tekton, Argo CD and Knative for Serverless Apps
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import doks from '@site/static/img/doks.png';
|
||||
import tekton from '@site/static/img/tekton_tasks.png';
|
||||
import tekton_pipelines from '@site/static/img/tekton_pipelines.png';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">Let's create a step-by-step plan to set up a CI/CD solution using free and widely used open-source tools that work smoothly on Kubernetes clusters.</div><br/>
|
||||
|
||||
<div className="text">Cloudtopiaa's Marketplace offers ready-to-use apps that you can set up with just a click on your Cloudtopiaa Kubernetes (CK) cluster. We'll use these 1-Click apps to quickly install each piece of software we need for our setup.</div><br/>
|
||||
|
||||
<div className="text">Learn to use Tekton to build a CI/CD pipeline that fetches code changes from a Git repository and builds a Docker image for your custom application. Then, Tekton will push the Docker image to a remote registry and notify Argo CD to deploy it to your Kubernetes cluster. This guide will also teach you how to use Knative Eventing to trigger the CI/CD pipeline each time code is automatically pushed to your application’s GitHub repository. All these steps run automatically.</div><br/>
|
||||
|
||||
<div className="text">In this guide, we'll use some helpful tools:</div>
|
||||
|
||||
<div className="text"><ol><li>Kaniko for building container images directly in a Kubernetes cluster.</li><li>Tekton pipelines and Argo CD for implementing the CI process.</li><li>Knative for running and exposing applications functionality on Kubernetes.</li><li>Cert-Manager for managing TLS termination of Knative Services.</li></ol></div>
|
||||
|
||||
<div className="text">After completing this blueprint, you will have a fully functional CI/CD pipeline.</div><br/>
|
||||
|
||||
<div className="text">Once you finish following this guide, you'll have a special system in place that automatically builds and updates your apps whenever you make changes to their code, using Kubernetes.</div><br/>
|
||||
|
||||
<div className="text">Look at this picture that shows everything we set up:</div><br/>
|
||||
|
||||
<img src={doks} alt="doks" /> <br/>
|
||||
|
||||
<div className="text">In the tutorial, you will learn:</div>
|
||||
|
||||
<div className="text"><ol><li>About components like Kaniko, Tekton, Argo CD and Knative.</li><li>How to install each component using Cloudtopiaa 1-Click apps.</li><li>How to configure the necessary components to respond to GitHub events and trigger the CI/CD pipeline.</li><li>How to implement and test the CI/CD flow and deploy a sample Knative application (2048 game).</li></ol></div>
|
||||
|
||||
|
||||
<div className="text"><ol><li>A personal web address (a domain you own). This is important for making some parts of your project visible to everyone. If you're not sure about this, check out the Cloudtopiaa DNS Quickstart Guide for help.</li><li>A special kind of computer system called CK, running Kubernetes (version 1.21 or newer). Your CK should be set up with at least 2 parts (we call them nodes), each with 2 CPUs, 4 GB of memory, and 20 GB of storage. For a step-by-step guide on how to set up CK, look at How to Set Up a Cloudtopiaa Managed Kubernetes Cluster.</li><li>A tool to talk to your code's home on GitHub – it's called a git client.</li><li>Another tool called doctl. It helps you talk to Cloudtopiaa's special computer system.</li><li>Kubectl is like a magic wand that lets you talk to the Kubernetes world. Follow these steps to connect it to your CK.</li><li>Helm is like a helper that makes things easier. You'll use it to talk to the special apps we set up on Cloudtopiaa</li><li>Argo CLI and Tekton CLI help you manage your code and projects.</li><li>Knative CLI is a tool for making your apps do amazing tricks in the Kubernetes world.</li><li>Kustomize is a little helper tool too. Don't worry if you're not familiar with it – you can start with our tutorial to get the hang of it.</li></ol></div>
|
||||
|
||||
<div className="text">And that's it! With these tools, you'll be all set to dive into the tutorial on Cloudtopiaa.</div>
|
||||
|
||||
<div className="text">Now, let's quickly meet each software component. This will help you understand what they do and how they work together.</div><br/>
|
||||
|
||||
<div className="head">Meet the Software Tools in Our Blueprint</div>
|
||||
|
||||
<div className="text">Think of Kaniko as a special tool that helps create containers directly in your Kubernetes world. It's a super handy way to build and share these containers without leaving your Kubernetes club. What's cool is that you can set up a complete system for your apps right there in your Kubernetes space. It's like having a helper that does all the work for you!</div><br/>
|
||||
|
||||
<div className="text">Behind the scenes, Kaniko is like a smart worker that doesn't need any special tools to build containers. It does all the work without relying on a specific helper called Docker daemon. This makes it great for building containers in places that might not easily or safely support that helper, like a regular Kubernetes club. Kaniko itself is like a mini expert that you use as an assistant.</div><br/>
|
||||
|
||||
<div className="text">For more details about Kaniko, you can check out its official project page.</div><br/>
|
||||
|
||||
<div className="text">In this guide, you'll learn to use Kaniko to create packages for your custom apps right from your Kubernetes club. It's a fun way to make your apps look cool and work smoothly!</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Meet Tekton: Your Code's New Friend</div>
|
||||
|
||||
<div className="text">Continuous Integration or CI, helps teams collaborate on big projects smoothly. It uses a shared online folder for all the project's code. Whenever someone adds new code, a special tool checks to ensure it works well with the existing code. This happens automatically, keeping the project up-to-date and functioning properly. Continuous Integration is a helpful way for teams to work together without causing issues in the code.</div>
|
||||
|
||||
<div className="text">In general, each CI automation follows a few simple steps:</div><br/>
|
||||
|
||||
<div className="text"><strong>Getting the Code:</strong><br/><ul><li>First, we take our application code from an online storage place.</li></ul></div>
|
||||
|
||||
<div className="text"><strong>Preparing it:</strong><br/><ul><li>Next, we use special tools to get our code ready.</li></ul></div>
|
||||
|
||||
<div className="text"><strong>Checking if it Works:</strong><br/><ul><li>Now, we test our code to make sure it does what it's supposed to, using methods like unit testing, integration testing, etc.</li></ul></div>
|
||||
|
||||
<div className="text"><strong>Creating the Final Version:</strong><br/><ul><li>Once everything is good, we finalize our code, often resulting in specific formats like a binary file, zip file, or Docker image.</li></ul></div>
|
||||
|
||||
<div className="text"><strong>Saving it for Later:</strong><br/><ul><li>Finally, we keep our final version safe for later use.</li></ul></div><br/>
|
||||
|
||||
|
||||
<div className="text">Tekton is a tool designed to help build systems that automatically test and deliver software. It works on top of Kubernetes, a system for managing large groups of software containers. With Tekton, developers can easily create these automated systems using small, reusable parts called Tasks. Tekton also comes with helpful tools like the Tekton CLI, which lets you control Tekton from your computer and a Catalog full of ready-to-use Tasks, making it easier to set up automated testing and delivery for your projects.</div><br/>
|
||||
|
||||
<div className="text">In this guide, Tekton manages the process of checking and building our code automatically. It uses a tool called a "Pipeline," along with others like "Tasks" and "Triggers." Think of Tekton as a helpful organizer that ensures our code is in good shape!</div><br/>
|
||||
|
||||
<div className="text">Tekton is set up in a neat and organized way. This tutorial uses different parts of Tekton to help with the checking and building of our code. It's like having a toolkit with specific tools for each job!</div><br/>
|
||||
|
||||
<div className="text">Tekton is like a set of organized tools. In this tutorial, we use specific Tekton parts to help with the part of software development where we check and build our code automatically. Think of it as using different tools to get a job done smoothly!</div><br/>
|
||||
|
||||
|
||||
<div className="text"><ol><li>asks: These are steps in a process, each with a specific job.</li><li>Pipelines: Think of them as the overall structure, organizing steps in a sequence.</li><li>Triggers and EventListeners: These respond to signals or events, like noticing changes and taking action.</li></ol></div><br/>
|
||||
|
||||
<div className="head">Tasks</div>
|
||||
|
||||
<div className="text">In Tekton, a Task is like giving your computer a to-do list. This list has smaller steps, similar to breaking down a big task into simple actions. Each step is a basic action, like building your code or saving it in a special place. You make a list of these steps in the order you want, and Tekton follows the list, doing each action one after the other. It's a way of telling your computer what to do in a clear and easy-to-follow way!</div><br/>
|
||||
|
||||
<div className="text">Tekton works by creating a special space in your computer called a Kubernetes Pod for each task. Inside these Pods, each step of the task is done inside a small container, sort of like a compartment in a toolbox. To know what to do, each container needs a special kind of blueprint called a Docker image. Which blueprint you choose depends on what you want each step to do.</div><br/>
|
||||
|
||||
|
||||
<div className="text"><ul><li>To run shell scripts, think of it like using a tool that's good at understanding and following instructions. It's called Alpine Linux.</li><li>For building something called a Dockerfile, imagine using a special tool called Google's Kaniko. It helps in putting together everything needed for a certain job.</li><li>If you want to control a tool named kubectl, you use a specific tool container called bitnami/kubectl. It's like using a special box that understands how to control this tool.</li><li>If you have your own special instructions, you can use an image that understands your unique commands. It's like having your own custom toolbox for specific tasks.</li></ul></div><br/>
|
||||
|
||||
<div className="text">Task definitions are made up of several parts, with the most important ones highlighted:</div>
|
||||
|
||||
<div className="text"><ul><li>Parameters: These are settings for a task, like how it should work or what names to use, such as compilation flags or the names of artifacts.</li><li>Workspaces: Think of these as shared spaces where different parts of a task can store and use information.</li><li>Results: These are like messages or important information that a task can send out. They can also be passed between different tasks in a sequence, helping them work together.</li></ul></div>
|
||||
|
||||
<div className="text">A usual Tekton Task definition might appear like this:</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: kaniko-example
|
||||
spec:
|
||||
params:
|
||||
- name: IMAGE
|
||||
description: Name (reference) of the image to build.
|
||||
- name: DOCKERFILE
|
||||
description: Path to the Dockerfile to build.
|
||||
default: ./Dockerfile
|
||||
results:
|
||||
- name: IMAGE_DIGEST
|
||||
description: Digest of the image just built.
|
||||
- name: IMAGE_URL
|
||||
description: URL of the image just built.
|
||||
steps:
|
||||
- name: build-and-push
|
||||
workingDir: $(workspaces.source.path)
|
||||
image: $(params.BUILDER_IMAGE)
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text"><ul><li>spec.params: This is where you list the things the task needs to work with.</li><li>spec.results: Here, you list the important things the task creates. These can be passed to other tasks.</li><li>spec.steps: This is where you list what the task should do step by step. Each step is like a small task within the bigger task, and they define how the task works.</li></ul></div>
|
||||
|
||||
<div className="note"><strong>Note: </strong>Task resources have been updated in Tekton, starting with version v1beta1 of the Tekton APIs. Instead of using Task resources directly, you are encouraged to use the new features as explained in the deprecation note. <br/> <br/> In Tekton, just creating a Task doesn't make it run. To make a Task actually do something, you create a separate thing called TaskRun. Think of TaskRun as pressing the play button for your Task - it starts doing the steps you defined in your Task. TaskRuns do the work by following the steps you set in your Task. They can also take in specific instructions, like what resources to use or what information to consider.<br/> <br/> Remember, tasks are like reusable tools you can share and use in different workflows. Tekton is special because it lets you build things with these reusable tools. And if you want even more tools, Tekton has a collection of them in the Tekton Catalog project to make your work even easier!</div><br/>
|
||||
|
||||
<div className="text">The image below shows how the concepts of Task and TaskRun work together:</div>
|
||||
|
||||
<img src={tekton} alt="tekton" /> <br/>
|
||||
|
||||
<div className="head">Pipelines</div>
|
||||
|
||||
<div className="text">A Tekton Pipeline helps you organize your tasks and control how your continuous integration (CI) process works. In a Pipeline, you specify the order in which your tasks should run. You can put tasks directly into a Pipeline, or you can use references to link to tasks defined in separate files. Using references is recommended because it helps avoid repeating the same code or settings, making things easier to manage. Tasks in Tekton are like tools that you can use and reuse across different pipelines. You can have separate pipelines for testing, building and deploying your app code, making it easier to manage each step of the process.</div>
|
||||
|
||||
<div className="text">In a Tekton Pipeline, you set up the plan for your tasks using:</div>
|
||||
|
||||
<div className="text"><ul><li>Parameters: These are like global settings that apply to all the tasks in your pipeline.</li><li>Workspaces: Think of these as shared spaces where tasks can store and share things.</li><li>Tasks: These are the actual steps in your plan.</li></ul></div>
|
||||
|
||||
<div className="text">A regular Tekton Pipeline definition might look something like this:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`apiVersion: tekton.dev/v1beta1
|
||||
kind: Pipeline
|
||||
metadata:
|
||||
name: kaniko-pipeline
|
||||
spec:
|
||||
params:
|
||||
- name: git-url
|
||||
- name: git-revision
|
||||
- name: image-name
|
||||
- name: path-to-image-context
|
||||
- name: path-to-dockerfile
|
||||
workspaces:
|
||||
- name: git-source
|
||||
tasks:
|
||||
- name: fetch-from-git
|
||||
taskRef:
|
||||
name: git-clone
|
||||
params:
|
||||
- name: url
|
||||
value: $(params.git-url)
|
||||
- name: revision
|
||||
value: $(params.git-revision)
|
||||
workspaces:
|
||||
- name: output
|
||||
workspace: git-source
|
||||
- name: build-image
|
||||
taskRef:
|
||||
name: kaniko
|
||||
params:
|
||||
- name: IMAGE
|
||||
value: $(params.image-name)
|
||||
- name: CONTEXT
|
||||
value: $(params.path-to-image-context)
|
||||
- name: DOCKERFILE
|
||||
value: $(params.path-to-dockerfile)
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: git-source
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Breaking down the provided configuration:</div>
|
||||
|
||||
<div className="text"><ul><li>spec.params: This section lists the input settings for the entire Pipeline.</li><li>spec.workspaces: Here, you list spaces that different tasks can use to share information between them. It's like having a common table where everyone can put and find things.</li><li>spec.tasks: This part outlines the steps to be done in order. These steps can be included directly in the Pipeline definition or referred to using a specific field. It's similar to listing the jobs you want to get done one after the other.</li></ul></div>
|
||||
|
||||
<div className="hint">The Tekton Catalog (or Hub) is like a store that offers pre-made task definitions for common tasks, such as copying a git repository or building a Docker image with kaniko. You can add these tasks to your Kubernetes cluster using either the tkn CLI or kubectl. Then, you can use these tasks in your own custom pipelines by referring to them with a specific field. It's like having a set of ready-to-use tools that you can easily pick and use in your own projects.</div><br/>
|
||||
|
||||
<div className="text">When you make a Tekton Pipeline, it doesn't start running right away. To make it do something, you need to create something called a PipelineRun. Think of a PipelineRun like starting your Tekton Pipeline. It runs the tasks you set up in your Pipeline.The PipelineRun works by following the steps you defined in your Pipeline. It does each task in the order you specified, making sure everything runs smoothly. If all tasks are successful, great! If there's a problem, it stops and lets you know something went wrong.</div><br/>
|
||||
|
||||
<div className="note">Pipeline resources have been updated in Tekton, starting with version v1beta1 of the Tekton APIs. Because of this, they're not used in this tutorial or recommended anymore. Instead, users are encouraged to use the new features.When you reference tasks within a Pipeline, the corresponding TaskRun objects are automatically created for you. You don't need to create them separately, making things simpler and more efficient.</div><br/>
|
||||
|
||||
<div className="text">The image below shows how Pipelines and Tasks fit together:</div>
|
||||
|
||||
<img src={tekton_pipelines} alt="tekton_pipelines" /> <br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Listening for Events and Triggering Actions</div>
|
||||
|
||||
|
||||
331
blog/2019-05-29-blog-24.md
Normal file
@ -0,0 +1,331 @@
|
||||
---
|
||||
slug: Easy and Secure File Transfers A Simple Guide to Using SFTP with a Remote Server
|
||||
title: Easy and Secure File Transfers A Simple Guide to Using SFTP with a Remote Server
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">FTP, which stands for File Transfer Protocol, used to be a common way to move files between computers. However, it's not very safe because it doesn't protect your files during the transfer. In 2022, most new software won't use it much anymore because it's not secure. People now prefer more secure methods. You might still find FTP in some old programs, but it's kind of like an outdated tool, and modern programs use safer ways to transfer files.</div><br/>
|
||||
|
||||
|
||||
<div className="text">SFTP or Secure File Transfer Protocol, is like a superhero version of regular file transfer. It's bundled with something called SSH, which makes sure your files are safe during the transfer. Imagine it as a super-secure way to share files between computers. It can do the same things as regular file transfer, but it's like the upgraded, safer version. You can use it whenever you need to share files securely, just like how you used to use regular file transfer.</div><br/>
|
||||
|
||||
<div className="text">SFTP is a safer way to share files compared to regular FTP. It has extra security features because it works with something called SSH. Think of SFTP as a very secure method to exchange files between computers. Regular FTP is not as safe and should only be used carefully or on networks you really trust.</div><br/>
|
||||
|
||||
<div className="text">Even though you can use SFTP with easy-to-use programs, we'll show you how to use its basic, command-line version. It's like learning the special abilities of SFTP through simple commands.</div><br/>
|
||||
|
||||
<div className="head">SFTP Connection Made Easy: A Step-by-Step Guide</div>
|
||||
|
||||
<div className="text">By default, SFTP uses the SSH protocol to verify and create a secure connection. This means it has the same ways of checking your identity as SSH.</div><br/>
|
||||
|
||||
<div className="text">While you can log in with a password, it's safer and more convenient to use something called 'SSH keys.' Think of these keys like a special passcode only your computer understands. It's a more secure way, and in the long run, it can be easier for you. We recommend using SSH keys for better security and a smoother experience.</div><br/>
|
||||
|
||||
<div className="text">Setting up SSH keys is like giving your computer a secure passcode. If you've done that, good job!</div><br/>
|
||||
|
||||
<div className="text">Now, if you can use SSH to connect to your computer (think of it like sending a message to your computer), you're ready to use SFTP to handle your files. To check, just use a command to make sure your computer can communicate with the other one.</div>
|
||||
|
||||
<CodeBlock code={`ssh sammy@your_server_ip_or_remote_hostname`} /><br/>
|
||||
|
||||
<div className="text">If everything is good, you can finish by typing:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">Now, you can start using SFTP by typing:</div>
|
||||
|
||||
<CodeBlock code={`sftp sammy@your_server_ip_or_remote_hostname`} /><br/>
|
||||
|
||||
<div className="text">After typing this command, you'll be connected to the other system, and your screen will show an SFTP prompt.</div><br/>
|
||||
|
||||
<div className="text">If you're using a different port number to communicate with your system (not the usual port 22), you can open the SFTP connection like this:</div>
|
||||
|
||||
<CodeBlock code={`sftp -oPort=custom_port sammy@your_server_ip_or_remote_hostname`} /><br/>
|
||||
|
||||
<div className="text">This will link you to the other system using the port you chose.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Need Help with SFTP? Here's What to Do</div>
|
||||
|
||||
<div className="text">The first command you should know is 'help.' It's like asking for directions in SFTP. To use it, just type either of these in the prompt:</div>
|
||||
|
||||
<CodeBlock code={`help`} /><br/>
|
||||
|
||||
OR
|
||||
|
||||
<CodeBlock code={`?`} /><br/>
|
||||
|
||||
<div className="text">This will show you a list of all the things you can do.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Available commands:
|
||||
bye Quit sftp
|
||||
cd path Change remote directory to 'path'
|
||||
chgrp grp path Change group of file 'path' to 'grp'
|
||||
chmod mode path Change permissions of file 'path' to 'mode'
|
||||
chown own path Change owner of file 'path' to 'own'
|
||||
df [-hi] [path] Display statistics for current directory or
|
||||
filesystem containing 'path'
|
||||
exit Quit sftp
|
||||
get [-Ppr] remote [local] Download file
|
||||
help Display this help text
|
||||
lcd path Change local directory to 'path'
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">We'll look at some of these commands in the next sections.</div>
|
||||
|
||||
<div ClassName="head">SFTP Basics: Exploring Your Files</div>
|
||||
|
||||
<div className="text">We can move around the remote system's folders using commands that work like those in a regular computer.</div><br/>
|
||||
|
||||
<div className="text">Let's start by figuring out where we are right now on the remote system. Just like when you check where you are on your own computer, you can type this to see the current folder:</div>
|
||||
|
||||
<CodeBlock code={`pwd`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Remote working directory: /home/demouser
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">We can check what's inside the current folder on the remote system using a command you're already familiar with:</div>
|
||||
|
||||
<CodeBlock code={`ls`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Summary.txt info.html temp.txt testDirectory
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Keep in mind that SFTP commands are a bit different from what you might be used to, and they don't have all the advanced features. However, you can still do important things. For instance, if you add -la to 'ls,' it shows more details about files, like when they were changed and who can access them:</div>
|
||||
|
||||
<CodeBlock code={`ls -la`} /><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
drwxr-xr-x 5 demouser demouser 4096 Aug 13 15:11 .
|
||||
drwxr-xr-x 3 root root 4096 Aug 13 15:02 ..
|
||||
-rw------- 1 demouser demouser 5 Aug 13 15:04 .bash_history
|
||||
-rw-r--r-- 1 demouser demouser 220 Aug 13 15:02 .bash_logout
|
||||
-rw-r--r-- 1 demouser demouser 3486 Aug 13 15:02 .bashrc
|
||||
drwx------ 2 demouser demouser 4096 Aug 13 15:04 .cache
|
||||
-rw-r--r-- 1 demouser demouser 675 Aug 13 15:02 .profile
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">To go to another folder, just type this command:</div>
|
||||
|
||||
<CodeBlock code={`cd testDirectory`} /><br/>
|
||||
|
||||
<div className="text">Now that we've explored the files on the other computer, what if we want to check our own files? It's easy! Just add an 'l' before the command. Every command we've talked about has a local version. For instance, to see where you are in your own computer, type:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`lpwd`} /><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Local working directory: /Users/demouser
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">We can see what's in the current folder on our own computer by typing:</div>
|
||||
|
||||
<CodeBlock code={`lls`} /><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Desktop local.txt test.html
|
||||
Documents analysis.rtf zebra.html`} /><br/>
|
||||
|
||||
<div className="text">We can also switch to a different folder on your computer like this:</div>
|
||||
|
||||
<CodeBlock code={`lcd Desktop`} /><br/>
|
||||
|
||||
<div className="head">SFTP Made Simple: How to Transfer Files with Ease</div>
|
||||
|
||||
<div className="text">If you want to bring files from your other computer to yours, you can use the 'get' command:</div>
|
||||
|
||||
<CodeBlock code={`get remoteFile`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Fetching /home/demouser/remoteFile to remoteFile
|
||||
/home/demouser/remoteFile 100% 37KB 36.8KB/s 00:01
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">When you use the 'get' command, it downloads a file from the other computer and gives it the same name on your computer.</div>
|
||||
|
||||
<div className="text">But if you want to give it a different name, just type the name you want after the 'get' command:</div>
|
||||
|
||||
<CodeBlock code={`get remoteFile localFile`} /><br/>
|
||||
|
||||
<div className="text">The 'get' command can do more! For example, if you want to copy a whole folder and everything inside it, just add the word 'recursive' after the 'get' command:</div>
|
||||
|
||||
<CodeBlock code={`get -r someDirectory`} /><br/>
|
||||
|
||||
<div className="text">To keep things organized, use the '-P' or '-p' flag with the command. This makes sure that the files keep their proper permissions and access times:</div>
|
||||
|
||||
<CodeBlock code={`get -Pr someDirectory`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Putting Files on the Remote System: A Step-by-Step Guide</div>
|
||||
|
||||
<div className="text">Sending files to the other computer is just as easy. Instead of 'get,' you use the 'put' command:</div>
|
||||
|
||||
<CodeBlock code={`put localFile`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Uploading localFile to /home/demouser/localFile
|
||||
localFile 100% 7607 7.4KB/s 00:00
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">You can use the same tricks for 'put' as you did with 'get.' For example, to copy a whole folder from your computer, just type 'put -r':</div>
|
||||
|
||||
|
||||
<CodeBlock code={`put -r localDirectory`} /><br/>
|
||||
|
||||
<div className="text">A helpful tool for checking if you have enough space for downloads and uploads is the 'df' command. It's like a tool you might use on your computer. With this, you can make sure you have enough room for the files you want to transfer.</div>
|
||||
|
||||
<CodeBlock code={`df -h`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Size Used Avail (root) %Capacity
|
||||
19.9GB 1016MB 17.9GB 18.9GB 4%
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Something to remember is that the 'df' command doesn't have a local version. But, you can still do it by using the '!' command.</div><br/>
|
||||
|
||||
<div className="text">The '!' command takes you to your own computer's command area. Here, you can run any command you normally would on your computer. To check disk usage, just type:</div>
|
||||
|
||||
<CodeBlock code={`!`} /><br/>
|
||||
|
||||
<div className="text">and then</div>
|
||||
|
||||
|
||||
<CodeBlock code={`df -h`} /><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Filesystem Size Used Avail Capacity Mounted on
|
||||
/dev/disk0s2 595Gi 52Gi 544Gi 9% /
|
||||
devfs 181Ki 181Ki 0Bi 100% /dev
|
||||
map -hosts 0Bi 0Bi 0Bi 100% /net
|
||||
map auto_home 0Bi 0Bi 0Bi 100% /home
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">You can use any other command as usual in your own computer. To go back to working with SFTP, just type:</div>
|
||||
|
||||
<CodeBlock code={`exit`} /><br/>
|
||||
|
||||
<div className="text">You'll see the SFTP prompt come back now.</div><br/>
|
||||
|
||||
<div className="head">Quick File Changes: Getting Started with SFTP</div>
|
||||
|
||||
<div className="text">With SFTP, you can do some basic file management tasks. For example, you can change who owns a file on the other computer by using this command:</div>
|
||||
|
||||
<CodeBlock code={`chown userID file`} /><br/>
|
||||
|
||||
<div className="text">Unlike the regular 'chmod' command, SFTP doesn't use usernames but something called UIDs. Unfortunately, you can't find out the UID directly from SFTP.</div><br/>
|
||||
|
||||
<div className="text">Instead, you can look in a file called '/etc/passwd' on the computer. This file connects usernames with UIDs in most Linux systems.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`get /etc/passwd
|
||||
!less passwd
|
||||
`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
|
||||
bin:x:2:2:bin:/bin:/bin/sh
|
||||
sys:x:3:3:sys:/dev:/bin/sh
|
||||
sync:x:4:65534:sync:/bin:/bin/sync
|
||||
games:x:5:60:games:/usr/games:/bin/sh
|
||||
man:x:6:12:man:/var/cache/man:/bin/sh
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Remember how we used the '!' command before? We used it before typing a command for our computer. It lets us run any command on our computer while still using SFTP. We could have used it with the 'df' command earlier to check disk space on our computer.</div><br/>
|
||||
|
||||
<div className="text">The UID you need is in the third part of each line in the file, separated by colons.</div><br/>
|
||||
|
||||
<div className="text">Similarly, you can change which group owns a file using this command:"</div>
|
||||
|
||||
<CodeBlock code={`chgrp groupID file`} /><br/>
|
||||
|
||||
<div className="text">Once more, there isn't a direct way to see all the groups on the other computer. But you can use this command to get a workaround:</div>
|
||||
|
||||
<CodeBlock code={`get /etc/group
|
||||
!less group
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
root:x:0:
|
||||
daemon:x:1:
|
||||
bin:x:2:
|
||||
sys:x:3:
|
||||
adm:x:4:
|
||||
tty:x:5:
|
||||
disk:x:6:
|
||||
lp:x:7:
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The third column shows the group ID linked to the name in the first column. That's what we need to know.</div><br/>
|
||||
|
||||
<div className="text">The 'chmod' command in SFTP works just like it does on your computer's files:</div>
|
||||
|
||||
<CodeBlock code={`chmod 777 publicFile`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Changing mode on /home/demouser/publicFile
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">You can't directly change permissions for files on your own computer using SFTP. But, you can adjust something called 'umask' to make sure new files you copy over have the right permissions.</div><br/>
|
||||
|
||||
<div className="text">You can do this using the 'lumask' command:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`lumask 022`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Local umask: 022
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, whenever you download regular files (unless you use the -p flag), they'll automatically have permissions set to 644. </div><br/>
|
||||
|
||||
<div className="text">You can also make directories on your computer with 'lmkdir' and on the other computer with 'mkdir'.</div><br/>
|
||||
|
||||
<div className="text">The other file commands we'll talk about are only for the other computer's files.</div>
|
||||
|
||||
<CodeBlock code={`ln
|
||||
rm
|
||||
rmdir
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">These commands do the same things as the ones you use on your computer. If you ever need to do these actions on your own files, just remember you can switch to your computer's command area by typing:</div>
|
||||
|
||||
<CodeBlock code={`!`} /><br/>
|
||||
|
||||
<div className="text">To run a command on your computer, just put '!' before the command. Like this:</div>
|
||||
|
||||
<CodeBlock code={`!chmod 644 somefile`} /><br/>
|
||||
<div className="text">When you're done with SFTP, just type 'exit' or 'bye' to finish and close the connection.</div>
|
||||
|
||||
<CodeBlock code={`bye`} /><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">SFTP might not have all the features of modern tools, but it's handy for certain tasks, especially if you're familiar with old FTP ways or need to limit what someone can do on your computer.</div><br/>
|
||||
|
||||
<div className="text">For example, you can let specific users transfer files without giving them full access to your computer. If you want to learn how, check our tutorial on 'How To Enable SFTP Without Shell Access.'If you're used to FTP or SCP, SFTP combines the best of both. It might not fit every situation, but it's a versatile tool to have.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to explore more? Check our tutorial for additional insights!</strong></div>
|
||||
150
blog/2019-05-29-blog-25.md
Normal file
@ -0,0 +1,150 @@
|
||||
---
|
||||
slug: Getting Java Ready Installation on Ubuntu 12.04 Made Simple
|
||||
title: Getting Java Ready Installation on Ubuntu 12.04 Made Simple
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">Before you dive into other cool things, you need to have Java on your computer. This guide will help you easily install and handle different versions of Java on Ubuntu 12.04.</div>
|
||||
|
||||
<div className="head">Default JRE/JDK Installation Made Simple</div>
|
||||
|
||||
<div className="text">This is the best and simplest choice. It will put OpenJDK 6 on Ubuntu 12.04 and older versions, and OpenJDK 7 on 12.10 and newer.</div><br/>
|
||||
|
||||
<div className="text">Installing Java with apt-get is straightforward. First, let's update the list of available software packages:</div>
|
||||
|
||||
<CodeBlock code={` sudo apt-get update`} /><br/>
|
||||
|
||||
<div className="text">Next, let's see if Java isn't already on your system:</div>
|
||||
|
||||
<CodeBlock code={`java -version`} /><br/>
|
||||
|
||||
<div className="text">If you see a message saying "The program java can be found in the following packages," it means Java isn't installed yet. In that case, run this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install default-jre`} /><br/>
|
||||
|
||||
<div className="text">This command installs the Java Runtime Environment (JRE). If you require the Java Development Kit (JDK), often needed for compiling Java applications like Apache Ant, Apache Maven, Eclipse, and IntelliJ IDEA, use the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install default-jdk`} /><br/>
|
||||
|
||||
<div className="text">Typically, you only need the JDK if you're going to build Java programs or if your software specifically asks for it, in addition to Java. The JDK includes the JRE, so there's no downside to installing it, except for the larger file size.</div>
|
||||
|
||||
<div className="text">Remember, the remaining steps are optional and should only be done when necessary.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Advanced Installation: Including OpenJDK 7 (Optional)</div>
|
||||
|
||||
<div className="text">To add OpenJDK 7 to your system, just run this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install openjdk-7-jre`} /><br/>
|
||||
|
||||
<div className="text">If you want the Java Development Kit (JDK) instead of just the Java Runtime Environment (JRE), use this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install openjdk-7-jdk`} /><br/>
|
||||
|
||||
|
||||
<div className="head">For Advanced Users: Installing Oracle JDK (Optional Step)</div>
|
||||
|
||||
<div className="text">The Oracle JDK is the main JDK, but it's not included by default in Ubuntu anymore.</div><br/>
|
||||
|
||||
<div className="text">You can still get it with apt-get. To install any version, just follow these steps:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install python-software-properties
|
||||
sudo add-apt-repository ppa:webupd8team/java
|
||||
sudo apt-get update
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">After that, depending on the version you need, run one of these commands:</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Oracle JDK 6 Made Simple: Installation Steps</div>
|
||||
|
||||
<div className="text">Even though it's an older version, some people still use it.</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install oracle-java6-installer`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Simple Setup: Installing Oracle JDK 8</div>
|
||||
<div className="text">This is a developer preview version, and the official release is coming soon. If you're curious about what Java 8 is all about, check out this article.</div><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo apt-get install oracle-java8-installer`} /><br/>
|
||||
|
||||
|
||||
<div className="head">Managing Java Versions (Optional Step)</div>
|
||||
|
||||
<div className="text">If you have different versions of Java on your system, you can choose which one to use by running this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo update-alternatives --config java`} /><br/>
|
||||
|
||||
<div className="text">It might show something like this if you have 2 installations (or more, if you have more):</div>
|
||||
|
||||
<CodeBlock code={`There are 2 choices for the alternative java (providing /usr/bin/java).
|
||||
|
||||
Selection Path Priority Status
|
||||
------------------------------------------------------------
|
||||
* 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 auto mode
|
||||
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
|
||||
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode
|
||||
Press enter to keep the current choice[*], or type selection number:
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Now, pick the number of the version you want as the default. You can also do this for the Java compiler (javac):</div>
|
||||
|
||||
<CodeBlock code={`sudo update-alternatives --config javac`} /><br/>
|
||||
|
||||
<div className="text">It's the same screen as before, and you use it in the same way. You can use this command for other things in Java that have different versions, like keytool, javadoc, and jarsigner.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Setting up 'JAVA_HOME': How to Make Java Work Right</div>
|
||||
|
||||
<div className="text">To set up the JAVA_HOME environment variable, which some programs need, start by finding where Java is installed on your computer:</div>
|
||||
|
||||
<CodeBlock code={`sudo update-alternatives --config java`} /><br/>
|
||||
|
||||
|
||||
<div className="text">It will show something like this:</div>
|
||||
|
||||
<CodeBlock code={`There are 2 choices for the alternative java (providing /usr/bin/java).
|
||||
|
||||
Selection Path Priority Status
|
||||
------------------------------------------------------------
|
||||
* 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 auto mode
|
||||
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
|
||||
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode
|
||||
|
||||
Press enter to keep the current choice[*], or type selection number:
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The installation path is listed for each one:</div>
|
||||
|
||||
<div className="text"><ol><li>/usr/lib/jvm/java-7-oracle</li><li>/usr/lib/jvm/java-6-openjdk-amd64</li><li>/usr/lib/jvm/java-7-oracle</li></ol></div>
|
||||
|
||||
<div className="text">Copy the path from the Java installation you like the most. Then, open and edit the file called /etc/environment:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/environment`} /><br/>
|
||||
|
||||
<div className="text">In that file, put in the following line (but replace YOUR_PATH with the path you copied):</div>
|
||||
|
||||
<CodeBlock code={`JAVA_HOME="YOUR_PATH"`} /><br/>
|
||||
|
||||
<div className="text">Now, to make sure everything's set up right, reload this file:</div>
|
||||
|
||||
<CodeBlock code={`source /etc/environment`} /><br/>
|
||||
|
||||
<div className="text">Check if everything is working by running:</div>
|
||||
|
||||
<CodeBlock code={`echo $JAVA_HOME`} /><br/>
|
||||
|
||||
<div className="text">If it shows the path you just set, then you've done it right! If not, double-check and make sure you followed all the steps correctly.</div><br/>
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">Great job! Now you've got Java up and running on your Ubuntu 12.04 computer. Whether you picked the default OpenJDK or went for the Oracle JDK, you're all set. We even learned how to manage different Java versions and set up the 'JAVA_HOME' thing. That's a big win! </div><br/>
|
||||
|
||||
<div className="text"><strong>Ready for more coding adventures?</strong></div>
|
||||
278
blog/2019-05-29-blog-26.md
Normal file
@ -0,0 +1,278 @@
|
||||
---
|
||||
slug: Managing Systemd Services and Units with Systemctl A Guide
|
||||
title: Managing Systemd Services and Units with Systemctl A Guide
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
|
||||
<div className="text">Systemd is an important part of many Linux computers. It acts like an organizer that helps your computer work smoothly. Understanding systemd might seem a bit challenging at first, but it's a powerful tool that simplifies managing your computer. Learning about systemd and its tools will give you more control and flexibility over your computer. It's like having a reliable assistant that makes your computer tasks easier. So, let's explore systemd together and see how it can become your computer's helpful companion!</div><br/>
|
||||
|
||||
<div className="text">In this guide, we'll explore a command called 'systemctl,' a powerful tool for managing how your computer starts and runs programs. We'll cover how to control programs, check their status, make changes and work with special files that control how everything functions.</div><br/>
|
||||
|
||||
<div className="text">Just so you know, not all computers use the same tools. If you come across a message like 'bash: systemctl is not installed,' it means your computer has a different setup. No worries, though – you can still learn a lot from this guide!</div><br/>
|
||||
|
||||
|
||||
<div className="head">Managing Services with Systemctl</div>
|
||||
|
||||
<div className="text">The init system is like the manager of your computer. Its main job is to get things ready after you turn on your computer, which we call 'userland' components. It also looks after special helpers called services and daemons while your computer is already up and running. Now, let's jump into some simple ways to take care of these services – it's like learning how to manage different tasks on your computer!</div><br/>
|
||||
|
||||
|
||||
<div className="text">In systemd, everything we want to control is called a 'unit.' Units are like different parts of your computer that systemd knows how to handle. Each unit is put into a group based on what it does, and we describe them using files called unit files. You can tell what type of unit it is by looking at the end of its file name.</div><br/>
|
||||
|
||||
<div className="text">When you're managing services, you'll mainly deal with something called 'service units.' These units have files with names ending in .service. But here's something cool: most of the time, you can just leave off the .service part when you're giving commands to systemd. It's clever enough to figure out that you're probably talking about a service!</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Getting Services Going and Turning Them Off</div>
|
||||
|
||||
<div className="text">To get a systemd service up and running, you use the start command. If you're not the main user of the computer, you'll need to add sudo before the command, because starting a service can change how the computer works:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo systemctl start application.service`} /><br/>
|
||||
|
||||
<div className="text">As we mentioned earlier, when you're dealing with services in systemd, you usually don't need to worry about typing the ".service" part. So, you can just type the command like this:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl start application`} /><br/>
|
||||
|
||||
<div className="text">While you can use the simplified command we mentioned earlier for most things, for better clarity in our instructions, we'll include the ".service" part in the following commands.</div><br/>
|
||||
|
||||
<div className="text">To turn off a service that's currently running, use the stop command instead:</div>
|
||||
|
||||
<div className="text">sudo systemctl stop application.service</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Refreshing and Rebooting Services</div>
|
||||
|
||||
<div className="text">To give a running service a fresh start, you can use the restart command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl restart application.service`} /><br/>
|
||||
|
||||
<div className="text">If the program you're using can update its settings without needing to restart, you can use the reload command to make that happen:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl reload application.service`} /><br/>
|
||||
|
||||
<div className="text">If you're not sure whether the service can update its settings without restarting, you can use the reload-or-restart command. This smart command will try to update the settings in place if possible. If not, it will simply restart the service with the new settings.</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl reload-or-restart application.service`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Turning Services On and Off</div>
|
||||
|
||||
<div className="text">The commands we talked about earlier are handy for turning services on or off while you're using your computer. But if you want a service to start automatically every time you turn on your computer, you need to tell systemd to do that.</div><br/>
|
||||
|
||||
<div className="text">To make a service start automatically when you boot up your computer, use the enable command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl enable application.service`} /><br/>
|
||||
|
||||
<div className="text">When you use the enable command, it basically creates a special link. This link points from where your computer usually keeps track of services (like in /lib/systemd/system or /etc/systemd/system) to the place where systemd checks for things to start automatically (usually /etc/systemd/system/some_target.target.wants).</div><br/>
|
||||
|
||||
<div className="text">Now, if you change your mind and don't want a service to start automatically anymore, you can type:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl disable application.service`} /><br/>
|
||||
|
||||
<div className="text">This will simply undo the special link that makes the service start automatically.</div><br/>
|
||||
|
||||
<div className="text">Remember, when you enable a service, it doesn't start running right away. If you want it to start now and also whenever you turn on your computer, you'll need to use both the start and enable commands.</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Checking How Services Are Doing</div>
|
||||
|
||||
<div className="text">To see how a service is doing on your computer, you can use the status command:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`systemctl status application.service`} /><br/>
|
||||
|
||||
<div className="text">This will give you information about the service, like whether it's running or not, where it's organized in the system, and some early details from its logs.</div><br/>
|
||||
|
||||
<div className="text">For example, if you check the status of an Nginx server, you might see something like this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
● nginx.service - A high performance web server and a reverse proxy server
|
||||
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
|
||||
Active: active (running) since Tue 2015-01-27 19:41:23 EST; 22h ago
|
||||
Main PID: 495 (nginx)
|
||||
CGroup: /system.slice/nginx.service
|
||||
├─495 nginx: master process /usr/bin/nginx -g pid /run/nginx.pid; error_log stderr;
|
||||
└─496 nginx: worker process
|
||||
Jan 27 19:41:23 desktop systemd[1]: Starting A high performance web server and a reverse proxy server...
|
||||
Jan 27 19:41:23 desktop systemd[1]: Started A high performance web server and a reverse proxy server.
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">This gives you a helpful summary of how the application is doing, letting you know if there are any issues or if anything needs your attention.</div><br/>
|
||||
|
||||
<div className="text">If you want to check if a unit (like a service) is currently doing its job (running), you can use the is-active command:</div>
|
||||
|
||||
<CodeBlock code={`systemctl is-active application.service`} /><br/>
|
||||
|
||||
<div className="text">This will tell you whether the unit (like a service) is currently working (active) or not (inactive). If it's active, you'll get a "0" exit code, which is handy for understanding results in shell scripts.</div><br/>
|
||||
|
||||
<div className="text">To check if the unit is set to start automatically, you can use the is-enabled command:</div>
|
||||
|
||||
<CodeBlock code={`systemctl is-enabled application.service`} /><br/>
|
||||
|
||||
<div className="text">This will show you if the service is set to start automatically or not. It'll also give you a "0" or "1" exit code to help you understand the answer.</div><br/>
|
||||
|
||||
<div className="text">Another thing you can check is if the unit (like a service) has run into any issues during startup. This is known as a "failed state," indicating there was a problem getting the unit started:</div>
|
||||
|
||||
<CodeBlock code={`systemctl is-failed application.service`} /><br/>
|
||||
|
||||
<div className="text">When you check, it will say "active" if everything's running smoothly, or "failed" if there's been a problem. If the unit was stopped on purpose, it might say "unknown" or "inactive." If you see a "0" exit status, it means something went wrong, while a "1" exit status means something else happened.</div><br/>
|
||||
|
||||
<div className="head">Understanding Your System's Situation</div>
|
||||
<div className="text">The commands we've talked about are great for handling individual services, but they don't give us a good picture of what's happening with the whole system. Luckily, there are some other systemctl commands that help with that.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Checking What's Going On</div><br/>
|
||||
<div className="text">To check out everything that's currently running on your computer, you can use the list-units command:</div>
|
||||
|
||||
<CodeBlock code={`systemctl list-units`} /><br/>
|
||||
|
||||
<div className="text">This will give you a list of everything that systemd is currently managing on your computer. It'll look something like this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
UNIT LOAD ACTIVE SUB DESCRIPTION
|
||||
atd.service loaded active running ATD daemon
|
||||
avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack
|
||||
dbus.service loaded active running D-Bus System Message Bus
|
||||
dcron.service loaded active running Periodic Command Scheduler
|
||||
dkms.service loaded active exited Dynamic Kernel Modules System
|
||||
getty@tty1.service loaded active running Getty on tty1
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The information you'll see is organized into columns:</div>
|
||||
<div className="text"><ul><li><strong>UNIT:</strong> The name of the thing systemd is managing.</li><li><strong>LOAD:</strong> It tells you if systemd has read the instructions for that thing. If it's "loaded," it means systemd knows what to do with it.</li><li><strong>ACTIVE:</strong> This gives you a quick summary of whether the thing is up and running. It's a simple way to know if it's working as it should</li><li><strong>SUB:</strong> This is a bit more detailed and specific to the type and state of the thing. It provides extra information about how the thing is doing.</li><li><strong>DESCRIPTION:</strong> A short description of what that thing is or what it does.</li></ul></div><br/>
|
||||
|
||||
<div className="text">When you run the list-units command, it usually shows only the units that are currently active. So, in the columns, you'll see "loaded" for whether systemd knows what to do with it, and "active" for whether it's up and running.Actually, when you just type systemctl without adding anything else, it does the same thing – it shows you the active units by default.</div>
|
||||
|
||||
<CodeBlock code={`systemctl`} /><br/>
|
||||
|
||||
<div className="text">If you want systemctl to show you more detailed information, you can add extra instructions called flags. For example, if you want to see all the units that systemd knows about, whether they're currently active or not, you can use the --all flag like this:</div>
|
||||
|
||||
<CodeBlock code={`systemctl list-units --all`} /><br/>
|
||||
|
||||
<div className="text">This will display all the units that systemd knows about, whether they're active or not. It includes units that systemd tried to load but couldn't find, as well as units that were active but are now inactive.</div><br/>
|
||||
|
||||
<div className="text">If you want to narrow down the results, you can use other flags. For instance, you can use --state= to specify whether you want to see information about what's loaded, active, or in a particular state. Don't forget to keep the --all flag so that systemctl shows units even if they're not currently active.</div>
|
||||
|
||||
<CodeBlock code={`systemctl list-units --all --state=inactive`} /><br/>
|
||||
|
||||
<div className="text">You can also use another filter called --type= to show only the type of units you're interested in. For instance, if you want to see only active service units, you can use:</div>
|
||||
|
||||
<CodeBlock code={`systemctl list-units --type=service`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Viewing All Unit Files</div><br/>
|
||||
|
||||
<div className="text">The list-units command shows only the units that systemd has tried to understand and use. However, this might not include all the units available on your system. To see every single unit file that your system has, even if systemd hasn't looked at them yet, you can use the list-unit-files command instead:</div>
|
||||
|
||||
<CodeBlock code={`systemctl list-unit-files`} /><br/>
|
||||
|
||||
<div className ="text">Units are like descriptions of things that systemd knows about. When you use list-unit-files, it doesn't show details from all those descriptions, just the names and their current state. The list has two columns: one for the unit file's name and one for its current state.</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
UNIT FILE STATE
|
||||
proc-sys-fs-binfmt_misc.automount static
|
||||
dev-hugepages.mount static
|
||||
dev-mqueue.mount static
|
||||
proc-fs-nfsd.mount static
|
||||
proc-sys-fs-binfmt_misc.mount static
|
||||
sys-fs-fuse-connections.mount static
|
||||
sys-kernel-config.mount static
|
||||
sys-kernel-debug.mount static
|
||||
tmp.mount static
|
||||
var-lib-nfs-rpc_pipefs.mount static
|
||||
org.cups.cupsd.path enabled
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The state you see will typically be one of these: enabled, disabled, static or masked.</div>
|
||||
<div className="text">In this case:</div>
|
||||
<div className="text"><ul><li>Enabled: The unit can be turned on.</li><li>Disabled: The unit is turned off.</li><li>Static: This means the unit doesn't have the necessary info to be turned on. It might do a one-time thing or is needed only by another unit.</li></ul></div>
|
||||
|
||||
<div className="text">We'll talk about what "masked" means in just a bit.</div><br/>
|
||||
|
||||
<div className="head">Controlling Units</div>
|
||||
<div className="text">Up until now, we've been dealing with services and checking what systemd knows about them. But there's more we can learn about these units using some extra commands. Let's dive into more details!</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Viewing Unit Details</div><br/>
|
||||
|
||||
<div className="text">To see the detailed instructions that systemd is using for a particular unit, you can use the cat command. This feature was added starting from systemd version 209. For example, to look at the unit file for the atd scheduling daemon, you could type:</div>
|
||||
|
||||
<CodeBlock code={`systemctl cat atd.service`} /><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
[Unit]
|
||||
Description=ATD daemon
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/usr/bin/atd
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
`} /><br/>
|
||||
|
||||
<div class="text">The output shows the set of instructions systemd is currently using for that unit. This could be useful if you've made changes to unit files or if you've adjusted specific options in a part of a unit file (we'll talk about this later).</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Checking Dependencies</div><br/>
|
||||
<div className="text">If you want to check all the things a unit depends on, you can use the list-dependencies command:</div>
|
||||
|
||||
<CodeBlock code={`systemctl list-dependencies sshd.service`} /><br/>
|
||||
|
||||
<div className="text">This will show you a map of dependencies, which are basically the things that need to be taken care of before the unit you're interested in can start. Dependencies include units that are necessary for or wanted by the units above them in the hierarchy.</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
sshd.service
|
||||
├─system.slice
|
||||
└─basic.target
|
||||
├─microcode.service
|
||||
├─rhel-autorelabel-mark.service
|
||||
├─rhel-autorelabel.service
|
||||
├─rhel-configure.service
|
||||
├─rhel-dmesg.service
|
||||
├─rhel-loadmodules.service
|
||||
├─paths.target
|
||||
├─slices.target
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you want to see all the dependencies, including those that keep going down the line, you can use the --all flag. This is particularly handy when dealing with .target units, which represent different system states.</div><br/>
|
||||
|
||||
<div className="text">If you're curious about which units depend on the one you're looking at, you can add the --reverse flag. Additionally, there are two more helpful flags: --before shows units that should start before the specified unit, and --after shows units that should start after the specified unit.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Inspecting Unit Details</div><br/>
|
||||
<div className="text">If you want to see the detailed properties of a unit, you can use the show command. This will give you a list of settings for that unit, displayed in a key=value format.</div>
|
||||
|
||||
<CodeBlock code={`systemctl show sshd.service`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Id=sshd.service
|
||||
Names=sshd.service
|
||||
Requires=basic.target
|
||||
Wants=system.slice
|
||||
WantedBy=multi-user.target
|
||||
Conflicts=shutdown.target
|
||||
Before=shutdown.target multi-user.target
|
||||
After=syslog.target network.target auditd.service systemd-journald.socket basic.target system.slice
|
||||
Description=OpenSSH server daemon
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you only want to see one specific detail, you can use the -p flag with the property name. For example, to find out about conflicts that the sshd.service unit might have, you can type:</div>
|
||||
|
||||
<CodeBlock code={`systemctl show sshd.service -p Conflicts`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Conflicts=shutdown.target`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Blocking and Unblocking Units</div>
|
||||
|
||||
<div className="text">In addition to stopping or disabling a service, systemd allows you to prevent a unit from starting altogether, whether it's done automatically or manually. This is known as "masking" the unit, and you can do it using the mask command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl mask nginx.service`} /><br/>
|
||||
|
||||
<div className="text">This will make sure that the Nginx service can't start, whether someone tries to start it automatically or manually, as long as it stays masked.</div><br/>
|
||||
|
||||
<div className="text">If you look at the list of unit files, you'll now see that the service is marked as "masked":</div>
|
||||
116
blog/2019-05-29-blog-3.md
Normal file
@ -0,0 +1,116 @@
|
||||
---
|
||||
slug: Creating a New User and Setting Permissions in MySQL
|
||||
title: Creating a New User and Setting Permissions in MySQL
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
<div className="head">Getting Started with MySQL</div>
|
||||
<div className="text">MySQL is like a helpful organizer for data, and it's free for everyone to use. It usually works with other tools like Linux, Apache, MySQL, and PHP (LAMP stack). Right now, it's the most popular free database out there. <br/><br/>
|
||||
This guide will show you how to make a new friend in MySQL (we call them a user) and give them special powers to do different things. Let's get started!</div>
|
||||
|
||||
<div className="head">What You Need Before We Start</div>
|
||||
<div className="text">Before we begin, you'll need to have something called a MySQL database. Imagine it like a safe place for information. This guide thinks you have this safe place on a special computer called a virtual private server, running a cool system called Ubuntu 20.04. But don't worry, the ideas we'll talk about work the same no matter where your database is.<br/> <br/>
|
||||
If you don't have a MySQL database yet and want to set one up, we have a guide on How To Install MySQL. It doesn't matter if your computer works with a different system – creating a new MySQL friend and giving them special powers will be pretty similar. Ready to go? Let's do it! <br/> <br/>
|
||||
<strong>Note: </strong>As we go through this guide, you might notice some parts of the commands that need your attention. We'll point them out with a special highlight like this. It's kind of like adding your own emojis to a message – just keep an eye out for these notes, and you'll know when to put your own touch on things!</div>
|
||||
|
||||
|
||||
<div className="head">Creating a New Friend in MySQL</div>
|
||||
<div className="text">When you install MySQL, it creates a special user called "root." This user can do pretty much anything in the database – it's like the boss! But because it's so powerful, we should only use it for important stuff. <br/> <br/>This step shows you how to use the root user to make a new friend (a user) and give them some powers.<br/> <br/>In Ubuntu systems running MySQL 5.7 and later, the root user doesn't use a password by default – it's a bit like having your house key always ready. But to make changes, you'll need to use a special command called sudo. This makes sure you have the right permissions to do what you want with MySQL. Ready to make some new friends? Let's go!</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text"><strong>Note: </strong>If your root MySQL user has a password, you'll need to use a different command to access the MySQL world. This command lets you use MySQL like a regular user, and you'll only get special privileges in the database if you enter the right password. It's like requiring a special key to unlock something - once you have it, you're in!</div><br/>
|
||||
|
||||
<CodeBlock code={`mysql -u root -p
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">Once you're in the MySQL world, you can create a new friend using a special command called CREATE USER. It's like putting together a puzzle – just follow the steps!</div><br/>
|
||||
|
||||
<CodeBlock code={`CREATE USER 'username'@'host' IDENTIFIED WITH authentication_plugin BY 'password';
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">After typing CREATE USER, you write down the name you want for your new friend. Then, you add an @ sign and the name of the place they'll be connecting from. If you're only letting them connect from your Ubuntu server, you can just write "localhost." Putting single quotes around both the name and the place isn't always required, but it can help avoid mistakes.<br/> <br/>You can pick how your user logs in to MySQL. The auth_socket plugin is easy because users don't need a password to get in. But it can also make it tricky for programs outside your computer to talk to MySQL because it blocks remote connections.<br/> <br/>Instead of specifying the authentication plugin, you can skip that part to let the user log in with MySQL's default security system, called caching_sha2_password. This is a good choice if you want to use a password for logging in because it's very secure.
|
||||
To create a user that uses caching_sha2_password, run this command. Just replace "sammy" with the username you want and pick a strong password that you'll remember.</div><br/>
|
||||
|
||||
<CodeBlock code={`CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password';
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text"><strong>Note: </strong>If you're using PHP for things like phpMyAdmin and facing issues with caching_sha2_password, no worries! You can create a user that uses the older, but still safe, plugin called mysql_native_password. This might help to avoid any problems when using PHP with your database.</div><br/>
|
||||
|
||||
<CodeBlock code={`CREATE USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">If you're not certain about which plugin to choose, don't worry! You can start by creating a user that uses the caching_sha2_plugin and if needed, you can adjust it later using the command: ALTER.</div><br/>
|
||||
|
||||
<CodeBlock code={`ALTER USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">Once you've made your new user, you can give them the right permissions.</div>
|
||||
|
||||
<div className="head">Giving User Permissions</div>
|
||||
|
||||
<div className="text">Here's the basic way to give a user permission to do things:</div> <br/>
|
||||
|
||||
<CodeBlock code={`GRANT PRIVILEGE ON database.table TO 'username'@'host';
|
||||
`} /> <br/>
|
||||
|
||||
|
||||
<div className="text">In this example, the PRIVILEGE value determines what the user can do with the specified database and table. You can give the user multiple permissions at once by separating them with commas. If you want to give the user permissions for all databases or tables, you can use asterisks (*) instead of specific names. In SQL, asterisks mean "all" databases or tables.<br/> <br/>Here's an example command: it gives a user the ability to do various things like creating, altering and dropping databases and tables. They can also add, update and delete data from any table and perform other actions like querying data and creating foreign keys. But keep in mind, it's a good idea to only give users the specific abilities they actually need. So, feel free to adjust what your user can do based on what tasks they should be able to perform. <br/> <br/>You can see the complete list of things users can do in the official MySQL documentation. To give these abilities to your user, just use the GRANT statement. Instead of "sammy," use the name of your own MySQL user. Easy, right?</div> <br/>
|
||||
|
||||
|
||||
<CodeBlock code={`GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">Keep in mind, this statement includes something called WITH GRANT OPTION. This means your MySQL user can share any permissions it has with other users on the system.<br/> <br/>
|
||||
<strong style={{ color:'red'}}>Caution: </strong>Be careful with granting the ALL PRIVILEGES privilege to your MySQL user. It gives them extensive powers, almost like being the boss (root user). Here's how some users might do it:</div> <br/>
|
||||
|
||||
<CodeBlock code={`GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
|
||||
`} /> <br/>
|
||||
|
||||
|
||||
<div className="text">Think twice before giving such extensive powers. If someone can access this MySQL user, they'll have complete control over all the databases on the server.<br/> <br/>Lots of guides recommend using the FLUSH PRIVILEGES command right after you make a NEW USER or give them special powers. This helps to make sure that the changes take effect right away.</div> <br/>
|
||||
|
||||
<CodeBlock code={`FLUSH PRIVILEGES;
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">But here's the thing: if you change the special settings using a statement like GRANT, the database will automatically update itself. So, you don't really need to use the FLUSH PRIVILEGES command in our case. But hey, running it won't harm anything either.<br/> <br/>If you ever need to take away a permission, the process is almost the same as giving it:</div> <br/>
|
||||
|
||||
|
||||
<CodeBlock code={`REVOKE type_of_permission ON database_name.table_name FROM 'username'@'host';
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text"><strong>Note: </strong>When you're taking away permissions, remember to use "FROM" in the command, not "TO" like you did when giving permissions.<br/> <br/>To check what a user can currently do, run the SHOW GRANTS command:</div> <br/>
|
||||
|
||||
|
||||
<CodeBlock code={`SHOW GRANTS FOR 'username'@'host';
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">Similar to deleting databases with DROP, you can use DROP to remove a user:</div> <br/>
|
||||
|
||||
<CodeBlock code={`DROP USER 'username'@'localhost';
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">Once you've made your MySQL user and given them special settings, you can leave the MySQL world by exiting the MySQL client:</div> <br/>
|
||||
|
||||
<CodeBlock code={`exit
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">In the future, when you want to sign in with your new MySQL user, just type a command like this:</div> <br/>
|
||||
|
||||
<CodeBlock code={`mysql -u sammy -p
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">With the -p flag, MySQL will ask you to type in your password when you want to log in with your MySQL user account. This is to make sure it's really you trying to access the account.</div> <br/>
|
||||
|
||||
<div className="con">Conclusion:</div> <br/>
|
||||
|
||||
<div className="text">After completing this tutorial, you now know how to make new users and give them different powers in a MySQL database. You can keep exploring and trying out different things with your MySQL users, or you might want to learn more about some advanced MySQL settings.<br/> <br/> <strong>Excited to manage your MySQL database?</strong><br/> <br/>Begin by making new users and deciding what they can do! Try out different settings to improve your database skills. Let's get started!</div> <br/>
|
||||
|
||||
|
||||
|
||||
699
blog/2019-05-29-blog-4.md
Normal file
@ -0,0 +1,699 @@
|
||||
---
|
||||
slug: Creating a Node.js App with Docker A Step-by-Step Guide
|
||||
title: Creating a Node.js App with Docker A Step-by-Step Guide
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
<br/>
|
||||
<span className="main-head">Creating a Node.js App with Docker: A Step-by-Step Guide</span>
|
||||
|
||||
<div className="head">Let's Dive into Docker!</div>
|
||||
|
||||
<div className="text">Ever heard of Docker? It's like a toolbox for developers! It helps us wrap up our apps neatly in what we call "containers." Think of a container as a tiny, self-contained space where your app can live and do its thing. <br/> <br/>Now, why do we like containers? Well, they're like super-light virtual machines, making our apps run smoothly without taking up too much space. <br/><br/>They also keep our apps separate from each other, like little islands, so they don't mess with one another.<br/><br/>Even though containers have been around for a while, they're becoming more popular because they give us cool perks like keeping our apps safe and making sure they all work the same way no matter where we run them. Let's explore how we can use Docker to make our apps even more awesome!<br/><br/>When you're using Docker to build and expand your app, the first step is usually making something called an "image." Think of it as a snapshot of everything your app requires to run smoothly. <br/><br/>
|
||||
This image is like a bundled package that contains your app's code, necessary tools, settings and what it needs to operate. Creating an image ensures that wherever your app runs, it always has a consistent setup and only carries what it absolutely needs. <br/> <br/>
|
||||
So, making an image is like preparing a special kit for your app, ensuring it's ready to work seamlessly anywhere you want it to!
|
||||
In this guide, you'll make a special package for a simple website using Express and Bootstrap. After that, you'll put your package into a container and save it on Docker Hub for later. Lastly, you'll take out your saved package from Docker Hub and use it to create another container. This shows how you can easily make copies and expand your website whenever you want!</div>
|
||||
|
||||
<div className="head">Requirements</div>
|
||||
|
||||
<div className="text">Before we get started, it's good to make sure your computer is using a somewhat recent version of Ubuntu. If you're on version 16.04 or an even older one, it's a good idea to upgrade to a newer version because the older ones don't get support anymore. Don't worry, though! We have some easy guides that'll help you upgrade your Ubuntu to the latest and greatest version. <br/> <br/>To try out this guide, make sure you have: <br/> <br/> <ol><li>A server running Ubuntu. You should also have a regular user account with the ability to use administrative commands (like sudo), and your firewall should be active. If you're not sure how to set these up, we have a guide to help you get started.</li> <br/> <li>Docker installed on your server. You can follow the first two steps of our guide titled "How To Install and Use Docker on Ubuntu" for Ubuntu versions 22.04, 20.04 or 18.04.</li> <br/> <li>Node.js and npm installed on your server. You can install them by following the instructions provided in our guide for Ubuntu versions 22.04, 20.04 or 18.04.
|
||||
</li> <br/> <li>A Docker Hub account. If you don't have one yet, don't worry! We have an introduction to help you get started with Docker Hub.</li></ol></div>
|
||||
|
||||
<div className="head">Creating Your Node.js App with Docker: Easy Steps</div>
|
||||
<div className="text"><ol><li><strong>Get Your App Ready</strong>:<br/>First things first, gather everything your app needs to run smoothly. It's like making sure you have all the tools before starting a craft project!</li><br/><li><strong>Build Your Node.js App</strong>:<br/>Craft the files for your Node.js app. This is where you put the magic code that makes your app work like a charm.</li><br/><li><strong>Guide Docker with Your App's Blueprint:</strong><br/>
|
||||
Write a "Dockerfile" to help Docker understand how to bundle up your app. It's like providing a recipe for Docker to cook up your app just right!</li> <br/><li><strong>Store Your App in the DockerHub Closet</strong>:<br/>Think of DockerHub as a big storage space. Put a copy of your app there so you can easily share it or use it again later. It's like having a safe spot for your digital stuff!</li></ol></div><br/>
|
||||
|
||||
<div className="text"><span className="text" style={{ fontSize:'28px' }}>Prepare Your App:</span><br/>First things first, get everything your app needs to run smoothly. It's similar to making sure you have all the tools before starting a craft project! To begin, create a special folder for your project in your computer's home area. We'll call ours "node_project," but feel free to pick a name you like:</div>
|
||||
|
||||
<CodeBlock code={`mkdir node_project`} /><br/>
|
||||
|
||||
<div className="text">Go to this folder: </div>
|
||||
|
||||
<CodeBlock code={` cd node_project`} /><br/>
|
||||
|
||||
<div className="text">This folder will be like the main hub of your project.<br/>
|
||||
Next up, make a file called "package.json." This file holds important details about your project, like what other things it needs to work. You can open this file with a program called "nano" or any other text editor you like.</div>
|
||||
|
||||
<CodeBlock code={`nano package.json`} /><br/>
|
||||
|
||||
<div className="text">Now, let's add some important details about your project. We'll include its name, your name as the creator, the type of license it uses, the starting point of your app and any other things your app needs to work. Make sure to replace the example author information with your own name and contact details!</div>
|
||||
|
||||
<CodeBlock code={`{
|
||||
"name": "nodejs-image-demo",
|
||||
"version": "1.0.0",
|
||||
"description": "nodejs image demo",
|
||||
"author": "Sammy the Shark <sammy@example.com>",
|
||||
"license": "MIT",
|
||||
"main": "app.js",
|
||||
"keywords": [
|
||||
"nodejs",
|
||||
"bootstrap",
|
||||
"express"
|
||||
],
|
||||
"dependencies": {
|
||||
"express": "^4.16.4"
|
||||
}
|
||||
}
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">This document holds important details about your project like its name, the person who made it (you!) and the rules for sharing it. When choosing a name for your project, make it short and describe what it does. Also, be sure it's unique and not already used by someone else. We've put the MIT license in there, which means others can freely use and share your app's code. It's like saying, "Hey, feel free to use this, just be cool about it!</div>
|
||||
|
||||
<div className="text">Also, in this file, you'll see:</div>
|
||||
<div className="text"><ol><li>"main": This points to the main file of your app, which will be called "app.js." You'll create this file next.</li><li>"dependencies": These are the other programs or tools your app needs to work properly. For now, it's just Express version 4.16.4 or newer.</li></ol></div>
|
||||
|
||||
<div className="text">Even though there's no repository listed here, you can add one later if you want to keep track of different versions of your app. It's like having a history of changes!</div>
|
||||
|
||||
<div className="text">Once you're done making changes, save and close the file. To get everything your project needs to run, just run this command:</div>
|
||||
|
||||
<CodeBlock code={`npm install`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Now, when you run this command, it will bring in all the things your project needs as listed in that "package.json" file we created earlier. So, let's move on to creating the files that make up your application!</div><br/>
|
||||
|
||||
|
||||
<span className="text" style={{ fontSize:'28px' }}>Build Your Node.js App:</span>
|
||||
<div className="text">Let's create a website that gives users cool info about sharks. Our app will have a main starting point called "app.js" and a folder called "views" where we'll keep the stuff that makes our site look cool.</div><br/>
|
||||
|
||||
<div className="text">We'll make a landing page, "index.html," that shows some basic shark facts and a link to a page with more detailed info, "sharks.html." In the "views" folder, we'll create both of these pages.</div><br/>
|
||||
|
||||
<div className="text">First things first, open up "app.js" in the main project folder. This is where we'll write the special instructions for our app.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`nano app.js`} /><br/>
|
||||
|
||||
<div className="text">The start of this file does some important stuff. It's like setting up the workspace for building our app. Here, we create the main tools (Express application and Router) we need for our website. We also set up some basic details, like where our project files are and the entrance number (port) for people to visit our site. It's like preparing the space for the cool things we're about to do!</div>
|
||||
|
||||
|
||||
<CodeBlock code={`const express = require('express');
|
||||
const app = express();
|
||||
const router = express.Router();
|
||||
|
||||
|
||||
const path = __dirname + '/views/';
|
||||
const port = 8080;
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The "require" function is like calling for a specific tool we need, in this case, it's Express, which helps us build our website. With Express, we create two important things: the app and the router. The router is like a guide that tells our website where to send people when they click on different links or buttons. We'll add these instructions as we go along. <br/><br/> We also set up two special names:</div>
|
||||
|
||||
<div className="text"><ol><li>"path" tells our app where to find our website files. In this case, it's inside a folder called "views" in our project.</li><li>"port" tells our app which door to open so people can visit our site. We've set it to listen for visitors on door number 8080.</li></ol></div>
|
||||
|
||||
<div className="text">Next, we'll start giving our app directions on how to handle different requests using the router.</div>
|
||||
|
||||
<CodeBlock code={`...
|
||||
|
||||
|
||||
router.use(function (req,res,next) {
|
||||
console.log('/' + req.method);
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
router.get('/', function(req,res){
|
||||
res.sendFile(path + 'index.html');
|
||||
});
|
||||
router.get('/sharks', function(req,res){
|
||||
res.sendFile(path + 'sharks.html');
|
||||
});
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The router.use function does something helpful - it loads a special tool called a "middleware" function. This tool helps us manage and process all the requests that come to our website, directing them to the right place. It's like having a guide to make sure everyone goes to the correct spots.</div> <br/>
|
||||
|
||||
<div className="text">After setting up this middleware, we decide what our website should do when someone asks for specific things:</div>
|
||||
|
||||
<div className="text"><ul><li>When someone visits the main URL of our website, we want to show them the "index.html" page.</li><li>If someone goes to a specific route called "/sharks" on our site, we'll show them the "sharks.html" page.</li></ul></div>
|
||||
|
||||
<div className="text">Finally, we tell our app to put all this together and start working. We also make sure it knows to be ready for visitors on port 8080, which is like saying, "Hey world, we're here and ready to share our cool website!</div>
|
||||
|
||||
<CodeBlock code={`...
|
||||
app.use(express.static(path));
|
||||
app.use('/', router);
|
||||
app.listen(port, function () {
|
||||
console.log('Example app listening on port 8080!')
|
||||
})
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The completed app.js file will appear as follows:</div>
|
||||
|
||||
<CodeBlock code={`const express = require('express');
|
||||
const app = express();
|
||||
const router = express.Router();
|
||||
const path = __dirname + '/views/';
|
||||
const port = 8080;
|
||||
router.use(function (req,res,next) {
|
||||
console.log('/' + req.method);
|
||||
next();
|
||||
});
|
||||
router.get('/', function(req,res){
|
||||
res.sendFile(path + 'index.html');
|
||||
});
|
||||
router.get('/sharks', function(req,res){
|
||||
res.sendFile(path + 'sharks.html');
|
||||
});
|
||||
app.use(express.static(path));
|
||||
app.use('/', router);
|
||||
app.listen(port, function () {
|
||||
console.log('Example app listening on port 8080!')
|
||||
})
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Once you're done, remember to save and close the file.<br/>
|
||||
Now, let's add some stuff that stays the same on our website, like pictures or styles. To begin, create a new folder called "views":</div>
|
||||
|
||||
<CodeBlock code={`mkdir views`} /><br/>
|
||||
|
||||
<div className="text">Open the first page of your website, index.html:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`nano views/index.html`} /><br/>
|
||||
|
||||
<div className="text">Add the following code to the file. This will bring in Bootstrap and create a cool-looking section with a link to more detailed shark information (sharks.html):</div>
|
||||
|
||||
<CodeBlock code={`<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
|
||||
<head>
|
||||
<title>About Sharks</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||
<link href="css/styles.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Merriweather:400,700" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<nav class="navbar navbar-dark bg-dark navbar-static-top navbar-expand-md">
|
||||
<div class="container">
|
||||
<button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
|
||||
</button> <a class="navbar-brand" href="#">Everything Sharks</a>
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav mr-auto">
|
||||
<li class="active nav-item"><a href="/" class="nav-link">Home</a>
|
||||
</li>
|
||||
<li class="nav-item"><a href="/sharks" class="nav-link">Sharks</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="jumbotron">
|
||||
<div class="container">
|
||||
<h1>Want to Learn About Sharks?</h1>
|
||||
<p>Are you ready to learn about sharks?</p>
|
||||
<br>
|
||||
<p><a class="btn btn-primary btn-lg" href="/sharks" role="button">Get Shark Info</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<h3>Not all sharks are alike</h3>
|
||||
<p>Though some are dangerous, sharks generally do not attack humans. Out of the 500 species known to researchers, only 30 have been known to attack humans.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<h3>Sharks are ancient</h3>
|
||||
<p>There is evidence to suggest that sharks lived up to 400 million years ago.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">At the top of the page, there's a menu that lets users switch between the Home and Sharks pages. Inside this menu, we're using a special feature from Bootstrap to highlight the current page. It's like making the page you're on stand out. We've also set up the links to our pages. The addresses here match the routes we decided on in the app.js file. It's a bit like setting up signposts that point to the different sections of our website.</div>
|
||||
|
||||
<CodeBlock code={`...
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav mr-auto">
|
||||
<li class="active nav-item"><a href="/" class="nav-link">Home</a>
|
||||
</li>
|
||||
<li class="nav-item"><a href="/sharks" class="nav-link">Sharks</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Also, we've added a button in the jumbotron section that takes you to our page with more information about sharks.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`...
|
||||
<div class="jumbotron">
|
||||
<div class="container">
|
||||
<h1>Want to Learn About Sharks?</h1>
|
||||
<p>Are you ready to learn about sharks?</p>
|
||||
<br>
|
||||
<p><a class="btn btn-primary btn-lg" href="/sharks" role="button">Get Shark Info</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">We also included a link to a special style sheet in the header:</div>
|
||||
|
||||
<CodeBlock code={`...
|
||||
<link href="css/styles.css" rel="stylesheet">
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">After you're done, remember to save and close the file.<br/><br/>
|
||||
Now that we have our main website page ready, let's make another page called "sharks.html." This page will have more details about sharks for those who are interested.<br/><br/>
|
||||
To get started, open up the file:</div>
|
||||
|
||||
<CodeBlock code={`nano views/sharks.html`} /><br/>
|
||||
|
||||
<div className="text">Now, let's add some code to this page. It will bring in Bootstrap and our custom style sheet, and then provide users with detailed information about different types of sharks.</div>
|
||||
|
||||
<CodeBlock code={`<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
|
||||
<head>
|
||||
<title>About Sharks</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||
<link href="css/styles.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Merriweather:400,700" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<nav class="navbar navbar-dark bg-dark navbar-static-top navbar-expand-md">
|
||||
<div class="container">
|
||||
<button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
|
||||
</button> <a class="navbar-brand" href="/">Everything Sharks</a>
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav mr-auto">
|
||||
<li class="nav-item"><a href="/" class="nav-link">Home</a>
|
||||
</li>
|
||||
<li class="active nav-item"><a href="/sharks" class="nav-link">Sharks</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="jumbotron text-center">
|
||||
<h1>Shark Info</h1>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<p>
|
||||
<div class="caption">Some sharks are known to be dangerous to humans, though many more are not. The sawshark, for example, is not considered a threat to humans.
|
||||
</div>
|
||||
<img src="https://assets.digitalocean.com/articles/docker_node_image/sawshark.jpg" alt="Sawshark">
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<p>
|
||||
<div class="caption">Other sharks are known to be friendly and welcoming!</div>
|
||||
<img src="https://assets.digitalocean.com/articles/docker_node_image/sammy.png" alt="Sammy the Shark">
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</html>
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Also, in this file, we're using a special class called "active" to show which page we're currently on.</div>
|
||||
|
||||
<div className="text">Once you're done, save and close the file.</div>
|
||||
|
||||
<div className="text">To wrap things up, let's make our custom style sheet that we linked to in both index.html and sharks.html. To start, create a new folder named "css" inside the "views" directory:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`mkdir views/css`} /><br/>
|
||||
|
||||
<div className="text">Open the CSS file:</div>
|
||||
|
||||
<CodeBlock code={`nano views/css/styles.css`} /><br/>
|
||||
|
||||
<div className="text">Now, let's put in the following code. This will give our pages the color and font style we want:</div>
|
||||
|
||||
<CodeBlock code={`.navbar {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
body {
|
||||
background: #020A1B;
|
||||
color: #ffffff;
|
||||
font-family: 'Merriweather', sans-serif;
|
||||
}
|
||||
h1,
|
||||
h2 {
|
||||
font-weight: bold;
|
||||
}
|
||||
p {
|
||||
font-size: 16px;
|
||||
color: #ffffff;
|
||||
}
|
||||
.jumbotron {
|
||||
background: #0048CD;
|
||||
color: white;
|
||||
text-align: center;
|
||||
}
|
||||
.jumbotron p {
|
||||
color: white;
|
||||
font-size: 26px;
|
||||
}
|
||||
.btn-primary {
|
||||
color: #fff;
|
||||
text-color: #000000;
|
||||
border-color: white;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
img,
|
||||
video,
|
||||
audio {
|
||||
margin-top: 20px;
|
||||
max-width: 80%;
|
||||
}
|
||||
div.caption: {
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">In this file, we not only set the font and color but also made sure the images won't be too big. We did this by saying they can't be wider than 80% of the page. This way, they won't take up more space than we want them to.</div> <br/>
|
||||
|
||||
<div className="text">Remember to save and close the file when you're done.</div> <br/>
|
||||
|
||||
<div classsName="text">Now that our application files are ready and the necessary tools are installed, it's time to start the application.</div><br/>
|
||||
|
||||
<div className="text">If you followed the setup guide at the beginning, you've set up a protective wall (firewall) around your server, allowing only certain types of communication. To let people access our site on door number 8080, run:</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw allow 8080`} /><br/>
|
||||
|
||||
<div className="text">To begin using your app, make sure you're inside the main folder of your project:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`cd ~/node_project`} /><br/>
|
||||
|
||||
<div className="">Run the program by typing 'node app.js'</div>
|
||||
|
||||
<CodeBlock code={`node app.js`} /><br/>
|
||||
|
||||
<div className="text">Open your web browser and go to http://your_server_ip:8080. This will take you to the main page of the website.</div>
|
||||
|
||||
<div className="text">Press the 'Get Shark Info' button. This will take you to a page with more information about sharks</div>
|
||||
|
||||
<div className="text">You have successfully started the application. When you're done, close the server by pressing CTRL+C. Now, let's create a Dockerfile to make it easy to use and expand this application.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Writing the Dockerfile:</div>
|
||||
|
||||
<div className="text">Your Dockerfile is like a recipe for Docker to understand how to bundle up your app. It specifies what should be included in your application container when it runs. This ensures that your application runs smoothly and consistently, regardless of where it's deployed.</div><br/>
|
||||
|
||||
<div className="text">By following these guidelines on building optimized containers, we aim to make our image as efficient as possible. This involves minimizing the number of image layers and keeping the image focused on a single purpose — recreating our application files and static content. To get started, head to your project’s root directory and create the Dockerfile. This file will be crucial in helping Docker understand how to package your application effectively.</div>
|
||||
|
||||
<CodeBlock code={`nano Dockerfile`} /><br/>
|
||||
|
||||
<div className="text">Docker images are like a stack of building blocks, each layer adding something new. Our first step is to choose the base block for our application. We'll start with the node:10-alpine image, which is recommended because it's the Long-Term Support (LTS) version of Node.js. This image is based on Alpine Linux, which helps keep our image size small.</div> <br/>
|
||||
|
||||
<div className="text">To make sure this choice fits your project, you can read more about it on the Docker Hub Node image page under the Image Variants section.
|
||||
To set this as the foundation for our application, just add the following line to our Dockerfile:</div>
|
||||
|
||||
<CodeBlock code={`FROM node:10-alpine`} /><br/>
|
||||
|
||||
<div className="text">This image already has Node.js and npm installed. Every Dockerfile must start with a FROM instruction.</div> <br/>
|
||||
|
||||
<div className="text">By default, the Docker Node image has a non-root 'node' user. It's safer to avoid running containers as root, and to only grant them the permissions they need. So, we'll use the 'node' user's home directory as our application's working directory. Inside the container, we'll also switch to using this 'node' user.</div><br/>
|
||||
|
||||
<div className="text">For more tips on how to work with the Docker Node image, you can check out this guide on best practices</div><br/>
|
||||
|
||||
<div className="text">To make sure our application code in the container has the right permissions, let's create two folders: 'node_modules' and 'app'. These folders will be created inside '/home/node'. By setting up these folders in advance, we ensure they have the correct permissions. This step is important because when we use 'npm install' to install local node modules in the container, we want to make sure everything works smoothly. We also need to make sure the folders are owned by our 'node' user.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`...
|
||||
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app`} /><br/>
|
||||
|
||||
<div className="text">To learn more about why it's helpful to combine multiple 'RUN' instructions, check out this discussion on managing container layers.</div> <br/>
|
||||
|
||||
<div className="text">Next, we'll set the working directory of our application to '/home/node/app'. This is where our application code will live inside the container.</div>
|
||||
|
||||
<CodeBlock code={`…
|
||||
WORKDIR /home/node/app`} /><br/>
|
||||
|
||||
<div className="text">If we don't specify a working directory, Docker will create one automatically. So, it's better to set it ourselves to be clear.</div><br/>
|
||||
|
||||
<div className="text">Next, let's copy the 'package.json' and 'package-lock.json' files. These files are important because they list all the dependencies our application needs to run correctly.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`...
|
||||
COPY package*.json ./
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">By placing the 'COPY' instruction before we run 'npm install' or copy the application code, Docker can optimize its process using caching. Each step in the build process is saved as a layer and Docker checks if it already has a cached layer for a specific instruction. If the 'package.json' file hasn't changed, Docker can reuse the existing layer, saving time by skipping the reinstallation of node modules.</div><br/>
|
||||
|
||||
|
||||
<div className="text">To make sure all application files, including those in the 'node_modules' directory, are owned by the non-root 'node' user, we switch to using the 'node' user before running 'npm install'. This helps maintain security and ensures proper permissions for our application files.</div>
|
||||
|
||||
<CodeBlock code={`...
|
||||
USER node
|
||||
`} /><br/>
|
||||
|
||||
|
||||
|
||||
<div className="text">Once we've copied the project dependencies and switched to using the 'node' user, we can now install the dependencies by running 'npm install'. This command will download and install all the necessary packages our application needs to run correctly.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`...
|
||||
RUN npm install
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Next, let's copy your application code into the application directory on the container. We'll make sure to set the appropriate permissions so that everything works smoothly.</div>
|
||||
|
||||
<CodeBlock code={`...
|
||||
COPY --chown=node:node . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">This step makes sure that all the application files belong to the non-root 'node' user.</div><br/>
|
||||
|
||||
<div className="text">Lastly, we'll open up port 8080 on the container and start running the application.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`
|
||||
...
|
||||
EXPOSE 8080
|
||||
CMD [ "node", "app.js" ]
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">The 'EXPOSE' command doesn't actually publish the port; instead, it's like a note to yourself and others about which ports your application will use when it's running.</div> <br/>
|
||||
|
||||
<div className="text">The 'CMD' command is what actually starts up your application inside the container. Here, it's running the command 'node app.js', which starts our Node.js application. Remember, you should only have one 'CMD' instruction in your Dockerfile.</div> <br/>
|
||||
|
||||
<div className="text">There's a lot more you can do with Dockerfiles! For a full list of instructions, you can check out Docker's Dockerfile reference documentation.</div> <br/>
|
||||
|
||||
<div className="text">Here's how the complete Dockerfile looks:</div> <br/>
|
||||
|
||||
|
||||
<CodeBlock code={`FROM node:10-alpine
|
||||
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
||||
WORKDIR /home/node/app
|
||||
|
||||
|
||||
COPY package*.json ./
|
||||
USER node
|
||||
RUN npm install
|
||||
COPY --chown=node:node . .
|
||||
EXPOSE 8080
|
||||
CMD [ "node", "app.js" ]
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After you're done making changes, remember to save and close the file.</div> <br/>
|
||||
|
||||
<div className="text">Before we build the application image, let's create a .dockerignore file. It works similarly to a .gitignore file – it tells Docker which files and directories in your project directory should not be copied into your container.</div> <br/>
|
||||
|
||||
<div className="text">Now, let's open the .dockerignore file.</div>
|
||||
|
||||
<CodeBlock code={`nano .dockerignore
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">In the .dockerignore file, list the names of the folders and files you don't want Docker to include in the image. These typically include your local node modules, npm logs, Dockerfile, and the .dockerignore file itself.</div>
|
||||
|
||||
<CodeBlock code={`node_modules
|
||||
npm-debug.log
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">If you're using Git, it's a good idea to add your .git directory and .gitignore file to the .dockerignore file as well.</div> <br/>
|
||||
|
||||
<div className="text">Once you've added all the necessary files to the .dockerignore file, save and close it.</div><br/>
|
||||
|
||||
<div className="text">Now, you're ready to build the application image using the 'docker build' command. Adding the '-t' flag allows you to give the image a name that's easy to remember. Since we'll be pushing the image to Docker Hub, let's include your Docker Hub username in the tag. We'll name the image 'nodejs-image-demo', but you can choose any name you like. Just make sure to replace 'your_dockerhub_username' with your actual Docker Hub username.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo docker build -t your_dockerhub_username/nodejs-image-demo .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The '.' in the command specifies that Docker should use the current directory as the location to build the image from.</div> <br/>
|
||||
|
||||
<div className="text">Building the image will take a little time, usually a minute or two. Once it's done, you can check the images to see if it was created successfully.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo docker images`} /><br/>
|
||||
|
||||
<div className="text">After running the command, you'll see some messages on your screen. These messages will show you what's happening as Docker builds your image. Once it's finished, you'll get some output that confirms the process is complete.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
your_dockerhub_username/nodejs-image-demo latest 1c723fb2ef12 8 seconds ago 73MB
|
||||
node 10-alpine f09e7c96b6de 3 weeks ago 70.7MB
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Now, we can create a container using the 'docker run' command. We'll add three flags to this command:</div><br/>
|
||||
|
||||
<div className="text">-p: This flag allows us to publish a port on the container and map it to a port on our host. By default, we'll use port 80 on the host, but you can change this if needed, especially if another process is already using that port. You can learn more about how this works by reading the discussion in the Docker documentation on port binding.</div><br/>
|
||||
|
||||
<div ClassName="text">-d: This flag tells Docker to run the container in the background, so it won't tie up your command line.</div><br/>
|
||||
|
||||
<div className="text">--name: This flag lets us give the container a name that's easy to remember.</div><br/>
|
||||
|
||||
<div className="text">Here's the command to run:</div>
|
||||
|
||||
<CodeBlock code={`sudo docker run --name nodejs-image-demo -p 80:8080 -d your_dockerhub_username/nodejs-image-demo`} /><br/>
|
||||
|
||||
<div className="text">After your container is running, you can check a list of all your running containers using the command 'docker ps'.</div>
|
||||
<CodeBlock code={`sudo docker ps`} /><br/>
|
||||
|
||||
<div className="text">You'll see some information displayed on your screen. This output will show you details about the containers that are currently running.</div> <br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
e50ad27074a7 your_dockerhub_username/nodejs-image-demo "node app.js" 8 seconds ago Up 7 seconds 0.0.0.0:80->8080/tcp nodejs-image-demo
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now that your container is up and running, you can access your application by opening your web browser and typing in your server's IP address without specifying a port.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`http://your_server_ip`} /><br/>
|
||||
|
||||
<div className="text">You'll see your application's main page load once more in your web browser.</div><br/>
|
||||
|
||||
<div className="text">Now that you've finished creating an image for your application, you can upload it to Docker Hub. This way, you'll have it stored online and can access it whenever you need.</div> <br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Storing Your App on DockerHub:</div>
|
||||
<div className="text">Think of DockerHub as a big online storage space. You can save a copy of your app there so you can easily share it or use it again later. It's like having a safe spot for your digital stuff! <br/> <br/> To start, log in to your Docker Hub account, which you should have created earlier.</div><br/>
|
||||
|
||||
<div className="text">sudo docker login -u your_dockerhub_username</div> <br/>
|
||||
|
||||
<div className="text">When asked, type in your Docker Hub account password. This will save your login details in a file called ~/.docker/config.json in your computer's home folder.</div><br/>
|
||||
|
||||
<div className="text">Now, you can upload your application image to Docker Hub. Use the tag you created earlier: your_dockerhub_username/nodejs-image-demo.</div>
|
||||
|
||||
<CodeBlock code={`sudo docker push your_dockerhub_username/nodejs-image-demo`} /><br/>
|
||||
|
||||
<div className="text">Now, let's see which containers are currently running on your computer.</div>
|
||||
|
||||
<CodeBlock code={`sudo docker ps`} /><br/>
|
||||
|
||||
<div className="text">You'll see some information displayed on your screen. This output will show you details about the containers that are currently running.</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
e50ad27074a7 your_dockerhub_username/nodejs-image-demo "node app.js" 3 minutes ago Up 3 minutes 0.0.0.0:80->8080/tcp nodejs-image-dem
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To stop your running app, find the special ID in the list that Docker showed you. Replace the highlighted part below with your unique ID:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo docker stop e50ad27074a7`} /><br/>
|
||||
|
||||
<div className="text">See a list of all your images by adding the -a flag:</div>
|
||||
|
||||
<CodeBlock code={`docker images -a`} /><br/>
|
||||
|
||||
<div className="text">After running the command, you'll see a list showing the name of your image. It might look like "your_dockerhub_username/nodejs-image-demo," and you'll also see the node image along with any other images you've created.</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
your_dockerhub_username/nodejs-image-demo latest 1c723fb2ef12 7 minutes ago 73MB
|
||||
<none> <none> 2e3267d9ac02 4 minutes ago 72.9MB
|
||||
<none> <none> 8352b41730b9 4 minutes ago 73MB
|
||||
<none> <none> 5d58b92823cb 4 minutes ago 73MB
|
||||
<none> <none> 3f1e35d7062a 4 minutes ago 73MB
|
||||
<none> <none> 02176311e4d0 4 minutes ago 73MB
|
||||
<none> <none> 8e84b33edcda 4 minutes ago 70.7MB
|
||||
<none> <none> 6a5ed70f86f2 4 minutes ago 70.7MB
|
||||
<none> <none> 776b2637d3c1 4 minutes ago 70.7MB
|
||||
node 10-alpine f09e7c96b6de 3 weeks ago 70.7MB
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">To clean up, use the following command to remove the stopped container and all images, including the ones that are not being used:</div>
|
||||
|
||||
<CodeBlock code={`docker system prune -a`} /><br/>
|
||||
|
||||
<div className="text">When you see a question in the output, type 'y' to confirm that you want to get rid of the stopped container and images. Just so you know, this will also delete your build cache.</div><br/>
|
||||
|
||||
<div className="text">Now, you've successfully removed the container running your app and the image itself. If you want to learn more about removing Docker stuff, check out this guide on How To Remove Docker Images, Containers, and Volumes.</div><br/>
|
||||
|
||||
<div className="text">Now that everything is cleaned up, you can get your application image back from Docker Hub:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`docker pull your_dockerhub_username/nodejs-image-demo`} /><br/>
|
||||
|
||||
<div className="text">List your images again to make sure everything has been cleaned up:</div>
|
||||
<CodeBlock code={`docker images`} /><br/>
|
||||
|
||||
<div className="text">Look at the output, and you should see your application image listed:</div>
|
||||
<CodeBlock code={`Output
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
your_dockerhub_username/nodejs-image-demo latest 1c723fb2ef12 11 minutes ago 73MB
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, you can recreate your container by using the command from Step 3:</div>
|
||||
<CodeBlock code={`docker run --name nodejs-image-demo -p 80:8080 -d your_dockerhub_username/nodejs-image-demo`} /><br/>
|
||||
|
||||
<div className="text">Check which containers are currently running by using the following command:</div>
|
||||
|
||||
<CodeBlock code={`docker ps`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
f6bc2f50dff6 your_dockerhub_username/nodejs-image-demo "node app.js" 4 seconds ago Up 3 seconds 0.0.0.0:80->8080/tcp nodejs-image-dem
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Go to http://your_server_ip once more to see your application in action.</div> <br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion</div>
|
||||
|
||||
<div className="text">In this guide, you built a simple website using Express and Bootstrap. You also made a special package for your app, called a Docker image. You used this image to create a container and shared it on Docker Hub. Later, you learned how to delete and rebuild your image and container using Docker Hub.</div> <br/>
|
||||
|
||||
<div className="text">Great job! Now, you can explore more and create awesome things with Docker.</div><br/>
|
||||
|
||||
<div className="text">If you have any questions or want to learn more, feel free to ask or check out additional resources. Happy coding!</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
275
blog/2019-05-29-blog-5.md
Normal file
@ -0,0 +1,275 @@
|
||||
---
|
||||
slug: Getting Your Website Online Apache Setup for Ubuntu or Debian
|
||||
title: Getting Your Website Online Apache Setup for Ubuntu or Debian
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
|
||||
<div className="head">Introduction:</div>
|
||||
|
||||
<div className="text">Apache is like the engine that runs many websites you visit every day. It's super popular and used by over half of all websites online! While there are other web servers out there, Apache is a great one to learn about because it's everywhere.</div><br/>
|
||||
|
||||
<div className="text">In this article, we'll talk about some basic settings in Apache that you can tweak to customize how your website works. We'll focus on how things are set up in Ubuntu and Debian, which are types of operating systems. They have a particular way of organizing Apache's settings that might be a bit different from other systems, but don't worry, we'll guide you through it step by step!</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Getting started:</div>
|
||||
<div className="text">Before we get started, it's important to make sure your Ubuntu system is up to date. If you're using an older version like 16.04 or below, it's a good idea to upgrade to a newer version. This is because older versions may not receive security updates anymore, which could make your system vulnerable.</div>
|
||||
|
||||
<div className="text">Don't worry though! We've got guides to help you through the upgrade process. Just follow along, and we'll make sure your system is ready to go!</div>
|
||||
|
||||
<div className="text">Before we begin, make sure you have the following:</div>
|
||||
<div className="text"><ul><li>A server running Ubuntu (an operating system).</li><li>A regular user account with special permissions (called sudo privileges).</li><li>A firewall set up to protect your server.</li></ul></div>
|
||||
|
||||
<div className="text">If you're not sure how to set these up, don't worry! We have guides to help you. Just choose your operating system (Ubuntu or Debian) from the list and follow our Initial Server Setup Guide.</div>
|
||||
|
||||
<div className="text">Now, before we start, you need to have Apache installed on your server. We've got tutorials to help you with that too! Depending on your Ubuntu version, follow either the "How to Install the Apache Web Server on Ubuntu" or "How to Install the Apache Web Server on Debian 10" tutorial. They'll walk you through the installation process step by step.</div>
|
||||
|
||||
<div className="head">Getting Started with Apache on Ubuntu: 5 Easy Steps</div>
|
||||
<div className="text"><ol><li>Understanding Apache's Folders: Learn where Apache keeps its important files.</li><li>Getting to Know the Apache2.conf File: Explore the main configuration file for Apache.</li><li>Adjusting Apache's Settings: Make changes to how Apache behaves across your entire server.</li><li>Creating Virtual Hosts: Set up separate configurations for different websites on your server.</li><li>Activating Websites and Features: Enable your websites and additional functionalities in Apache.</li></ol></div> <br/>
|
||||
|
||||
<div className="head">Understanding Apache's Folders:</div>
|
||||
<div className="text">Apache stores its important files in a special folder called /etc/apache2. This folder is where you can find all the settings and configurations for your Apache web server. To see what's inside this folder, you can use a command that lists all the files.</div>
|
||||
|
||||
<CodeBlock code={`ls -f /etc/apache2`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
envars sites-available . apache2.conf .. sites-enabled mods-available ports.conf magic mods-enabled conf-enabled conf-available
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Inside this folder, you'll see a bunch of simple text files and a few folders. Here are some key places you should know about:</div>
|
||||
|
||||
<div className="text"><ol><li>apache2.conf: This is the main settings file for the server. Most settings are managed here, but it's recommended to use separate files for easier organization. This file sets up defaults and is where the server looks for configuration details.</li><br/><li>ports.conf: This file sets the ports that virtual hosts should use. It's important to check this file if you're setting up SSL (secure connections).</li><br/><li>sites-available/ and sites-enabled/: In the sites-available folder, you'll find configurations for virtual hosts (websites). These configurations determine which content gets served for different requests. The sites-enabled folder contains active virtual host configurations. Apache reads these files when it starts up or reloads to compile the full configuration.</li><br/><li>conf-available/ and conf-enabled/: These folders hold extra configuration pieces that aren't specific to virtual hosts.</li><br/><li>mods-available/ and mods-enabled/: Here, you'll find optional modules that Apache can load. Files ending in .load load the modules, while those ending in .conf store module configurations.</li></ol></div>
|
||||
|
||||
<div className="text">In Apache, configuration isn't done in just one big file. Instead, it's set up in a modular way. This means you can add and change settings by working with different files, making it easier to manage your server.</div> <br/>
|
||||
|
||||
|
||||
<div className="head">Getting to Know the Apache2.conf File:</div>
|
||||
<div className="text">The main settings for your Apache server are stored in a file called apache2.conf, located in the /etc/apache2/ folder. This file is divided into three main parts:</div>
|
||||
|
||||
<div className="text"><ol><li>Settings for the overall Apache server process.</li><li>Settings for the default server.</li><li>Settings for virtual hosts.</li></ol></div>
|
||||
|
||||
<div className="text">You can open this file using any text editor you like. For example, you can use a simple one called nano.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/apache2.conf`} /><br/>
|
||||
|
||||
<div className="text">In Ubuntu and Debian, the apache2.conf file is where you set up global settings for your server. Instead of cramming all settings into one file, you use the Include directive to bring in other configuration files. This helps keep things organized.</div><br/>
|
||||
|
||||
<div className="text">Inside apache2.conf, you'll see statements like Include and IncludeOptional. These tell Apache to read additional files, such as module definitions, ports.conf, configurations from the conf-enabled/ folder, and virtual host settings from the sites-enabled/ folder. This way, Apache puts together all the settings it needs when it starts up.</div>
|
||||
|
||||
<CodeBlock code={`…
|
||||
IncludeOptional mods-enabled/*.load
|
||||
IncludeOptional mods-enabled/*.conf
|
||||
…
|
||||
Include ports.conf
|
||||
…
|
||||
IncludeOptional conf-enabled/*.conf
|
||||
…
|
||||
IncludeOptional sites-enabled/*.conf
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="head">Adjusting Apache's Settings:</div>
|
||||
|
||||
<div className="text">Now, let's make some changes to how Apache works on your server. We'll adjust settings that affect the entire server, so it's important to get these settings right.</div><br/>
|
||||
|
||||
<div className="text">When setting up your Apache server, it's essential to understand and adjust some key parameters to optimize its performance. Here's a breakdown of important settings:</div>
|
||||
|
||||
<div className="text"><ol><li>Timeout: By default, Apache gives itself 300 seconds to complete each request. You can safely lower this to between 30 and 60 seconds for faster responses.</li><br/><li>KeepAlive: When KeepAlive is turned on, it lets one connection handle multiple requests from the same client. If it's turned off, each request requires a new connection, which can increase overhead. Keeping KeepAlive on can save time, especially if you have a lot of traffic.</li><br/><li>MaxKeepAliveRequests: This setting determines how many requests each connection can handle before it's closed. A higher value allows Apache to serve content more efficiently. The default setting is 100, but you can set it to 0 for an unlimited number of requests per connection.</li><br/><li>KeepAliveTimeout: This specifies how long Apache should wait for the next request after completing the last one. If the timeout is reached, the connection is closed. The default is 5 seconds.</li></ol></div><br/>
|
||||
|
||||
<div className="text">After making changes, you can close the configuration file by pressing CTRL+X.</div>
|
||||
<div className="text">Multi-Processing Modules (MPMs):</div>
|
||||
<div className="text">These extend Apache's capabilities to listen for, direct, and handle various network requests. You can find out which MPM your Apache uses by running a specific command.</div>
|
||||
|
||||
<CodeBlock code={`apache2 -L`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
Compiled in modules:
|
||||
core.c
|
||||
mod_so.c
|
||||
mod_watchdog.c
|
||||
http_core.c
|
||||
mod_log_config.c
|
||||
mod_logio.c
|
||||
mod_version.c
|
||||
mod_unixd.c
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To find out the type of Multi-Processing Module (MPM) your server is using, you can use the command: a2query -M.</div>
|
||||
|
||||
<CodeBlock code={`a2query -M`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
event`} /><br/>
|
||||
|
||||
|
||||
|
||||
<div className="text">The result shows that the event MPM is being used on this server. Your setup might offer different options, but you can only choose one at a time.</div>
|
||||
|
||||
<div className="head">Creating Virtual Hosts:</div>
|
||||
<div className="text">Now, let's set up individual configurations for different websites on your server. This helps Apache know which content to serve for each website you host.</div>
|
||||
|
||||
<div className="text">You'll find a default virtual host declaration in a file called 000-default.conf within the sites-available/ directory. You can take a look at this file to understand the basic format of a virtual host configuration.</div>
|
||||
|
||||
<div className="text">To open the file, use the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/sites-available/000-default.conf
|
||||
|
||||
<VirtualHost *:80>
|
||||
…
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/html
|
||||
…
|
||||
ErrorLog $ {APACHE LOG DIR}/error.log
|
||||
CustomLog $ {APACHE LOG DIR}/access.log combined
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The default virtual host is set up to deal with any requests on port 80, which is the standard for HTTP. You'll see this in the declaration header, where it says *:80, meaning it's listening on port 80 on any interface.</div><br/>
|
||||
|
||||
<div className="text">But just because it's set up this way doesn't mean it will handle every request to the server on this port. Apache looks for the most specific virtual host definition that matches the request. If it finds one that's more specific, it'll use that instead.</div><br/>
|
||||
|
||||
<div className="text">After you're done checking out the file, you can close it by pressing CTRL+X.</div><br/>
|
||||
<div className="text">Exploring Apache Virtual Host Settings:</div> <br/>
|
||||
|
||||
<div className="text">In the virtual host configuration, you'll find various options that apply to the entire virtual host. These settings are separate from any other specific configurations.</div><br/>
|
||||
|
||||
<div className="text">To begin, let's take a look at the security.conf file located in the conf-available/ directory.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/conf-available/security.conf`} /><br/>
|
||||
|
||||
<div className="text">In this file, there's a setting called "Server Signature" which allows you to specify an email address for server-related issues. By default, it's set to "On," but switching it to "EMail" will display the server admin's email address.</div><br/>
|
||||
|
||||
<div className="text">Remember, if you make this change, be prepared to receive emails regarding server problems.</div>
|
||||
|
||||
<CodeBlock code={`…
|
||||
ServerSignature EMail
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To exit the file, press CTRL+X. After you've made changes, a prompt will ask if you want to save them. Press Y to save or N to discard.</div><br/>
|
||||
|
||||
<div className="text">In your virtual host file, you can include a directive called ServerName. This specifies the domain name or IP address that this request should handle. If it matches the ServerName value, it'll override the default definition.</div><br/>
|
||||
|
||||
<div className="text">To open your virtual host file, use the following command, replacing "your_domain" with your actual domain name:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/sites-available/your_domain.conf`} /><br/>
|
||||
|
||||
<div className="text">Add your domain name to the ServerName directive.Just include your actual domain name after the ServerName directive in the virtual host file.</div>
|
||||
|
||||
<CodeBlock code={`…
|
||||
ServerName your_domain
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">You can make the virtual host apply to multiple names using the ServerAlias directive. This allows you to specify alternate paths to access the same content. For example, a common use case is adding "www" before your domain name.</div>
|
||||
|
||||
<CodeBlock code={`…
|
||||
ServerAlias www.your_domain.com
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The DocumentRoot directive tells Apache where to look for the content for this virtual host. On Ubuntu, the default setup serves content from the /var/www/ directory.</div><br/>
|
||||
|
||||
<CodeBlock code={`…
|
||||
DocumentRoot /var/www/your_domain/public_html
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="head">Managing Directory Settings:</div>
|
||||
<div className="text">Within the virtual host configuration, there are rules for how the server handles different directories on the file system. Apache applies these rules in a specific order, from shortest to longest directory paths. This allows later rules to potentially override earlier ones. <br/><br/> To open the apache2.conf file, use this command:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/apache2.conf
|
||||
…
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all denied
|
||||
</Directory>
|
||||
<Directory /usr/share>
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
<Directory /var/www/>
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
…
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The first directory definition sets rules for the root directory (/), which is the starting point for all files on the server. This configuration serves as the foundation for your virtual host, applying to all files on the file system.Take note of the directory settings and helpful comments in this file. By default, access to all content is denied unless specified otherwise in later directory definitions</div><br/>
|
||||
|
||||
<div className="text">The Require directive decides who can access different parts of your server. Meanwhile, the AllowOverride directive determines if an .htaccess file can change settings in the content directory. By default, this is not allowed, but it can be handy to enable in certain situations. After you're done looking at this file, you can close it by pressing CTRL+X.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Handling Aliases and Scripts:</div>
|
||||
|
||||
<div className="text">Before defining directories, you might encounter Alias or ScriptAlias directives. These instructions help Apache manage specific paths on your server.To open your virtual host configuration file, use this command, and remember to replace "your_domain" with your actual domain name:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/sites-available/your_domain.conf`} /><br/>
|
||||
|
||||
<div className="text">The Alias directive helps Apache connect a URL path to a directory path. For example, in a virtual host for your_domain, using this directive lets you access content stored in /usr/local/apache/content/ when you visit your_domain.com/content/.</div><br/>
|
||||
|
||||
<CodeBlock code={`Alias “/content/” “/usr/local/apache/content/”`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Just like the Alias directive, the ScriptAlias directive connects a URL path to a directory path. However, it's specifically used for directories that contain executable components.</div>
|
||||
|
||||
<CodeBlock code={`ScriptAlias "/cgi-bin/" "/usr/local/apache2/cgi-bin/"`} /><br/>
|
||||
|
||||
<div className="text">After you finish making changes to the file, remember to save your edits by pressing CTRL+X. If you've made changes, you'll be asked if you want to save them. Press Y for yes, or N for no to discard them.And don't forget to define the directory with the appropriate access privileges as explained earlier!</div><br/>
|
||||
|
||||
|
||||
<div className="head">Activating Websites and Features:</div>
|
||||
|
||||
<div className="text">Once you've set up your virtual host file just the way you want it, you can use Apache's tools to turn it into a live website. To do this, you'll create a symbolic link in the sites-enabled directory that points to your virtual host file in the sites-available directory. Here's the command to do that. Just make sure to replace "your_domain" with the name of your own virtual host site configuration file:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2ensite your_domain`} /><br/>
|
||||
|
||||
<div className="text">After you've activated a site, use this command to let Apache know to update its settings, making sure the changes you made take effect:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl restart apache2`} /><br/>
|
||||
|
||||
<div className="text">There's a way to turn off a virtual host too. You do this by deleting the symbolic link from the sites-enabled directory. For instance, if you have the default 000-default site enabled, you can disable it like this:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2dissite 000-default`} /><br/>
|
||||
|
||||
<div className="text">You can turn modules on or off using the a2enmod and a2dismod commands. They're similar to the a2ensite and a2dissite commands.For instance, if you want to activate the info module, you can use this command:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2enmod info`} /><br/>
|
||||
|
||||
<div className="text">Similarly, if you want to turn off a module, you can use the a2dismod command:</div>
|
||||
|
||||
<CodeBlock code={`sudo a2dismod info`} /><br/>
|
||||
|
||||
<div className="text">Don't forget to restart Apache after you've made changes to configuration files or after enabling or disabling modules.</div><br/>
|
||||
|
||||
<div className="con">Conclusion</div><br/>
|
||||
|
||||
<div className="text">Apache is flexible and made up of many parts, so the settings you need might vary based on your setup. After looking at some common scenarios, you should have a good grasp of what the main configuration files do and how they work together.</div><br/>
|
||||
|
||||
<div className="text">If you want to learn about specific settings, the files we've talked about have helpful comments, and Apache offers great documentation. Hopefully, you're feeling less overwhelmed by the configuration files now, and you're ready to try making changes to fit your needs</div> <br/>
|
||||
|
||||
<div className="text">Remember, if you have any questions or need further assistance, feel free to ask!</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
779
blog/2019-05-29-blog-6.md
Normal file
@ -0,0 +1,779 @@
|
||||
---
|
||||
slug: Automatically Adjusting App Size in Kubernetes with Horizontal PodAutoscale
|
||||
title: Automatically Adjusting App Size in Kubernetes with Horizontal PodAutoscale
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
<div className="head">Introduction</div>
|
||||
|
||||
<div className="text">In the real world, when you run your applications, you want them to be strong and able to handle lots of users without crashing. But you also want to save money by not using more resources than you need. So, you need a tool that can make your applications get bigger or smaller depending on how many people are using them.</div><br/>
|
||||
|
||||
<div className="text">Usually, when you set up your apps in Kubernetes, you decide on a fixed number of copies to run all the time. But in real-life situations, like when many people visit your website or use your app, this fixed setup might not work well. It's like trying to fit everyone into the same-sized room, even when the crowd keeps changing. For example, if your website gets more visitors in the afternoon or during holidays, it could slow down or crash. This happens because there aren't enough copies of your app to handle all the requests. Manually changing the number of copies each time this happens can be a hassle. Plus, it's not efficient because you'd end up using more resources than you need, costing you more money. So, it's better to have a way for your apps to automatically adjust their size based on how busy they are. That way, they can handle more visitors when needed and use fewer resources when things calm down.</div><br/>
|
||||
|
||||
<div className="text">This is where Horizontal Pod Autoscaling comes in! It's a clever system that automatically adjusts your app's size to handle more or fewer visitors, saving you money. Think of it as a tool that watches how busy your app is and adds more capacity when needed, or removes it when things calm down. So, you don't have to worry about manually changing things all the time.</div><br/>
|
||||
|
||||
<div className="text">Horizontal pod scaling focuses on adding or removing resources for your app, while vertical pod scaling focuses on making sure each resource has enough capacity to run smoothly.</div>
|
||||
|
||||
<div className="head">How Horizontal Pod Autoscaling Keeps Your Apps Running Smoothly</div>
|
||||
|
||||
<div className="text"><ol><li>Watching Your App: HPA keeps an eye on how much your app is using resources like CPU and memory.</li><li>Comparing and Deciding: It compares how many resources your app is using with a target value you set. If your app is using more resources than it should, HPA knows it needs to do something.</li><li>Scaling Up or Down: If your app is using a lot of resources, HPA can make your app bigger by adding more parts to it. This helps your app handle more users without slowing down. But if your app isn't using many resources, HPA can make your app smaller by removing some parts. This saves resources and money.</li></ol></div>
|
||||
|
||||
<div className="text">If you want to know more about how HPA decides when to make your app bigger or smaller, you can check out the details in the official documentation.</div><br/>
|
||||
|
||||
<div className="text">Behind the scenes, a HorizontalPodAutoscaler is just another CRD (Custom Resource Definition) that powers a special feature in Kubernetes. It works like a helpful tool that tells Kubernetes when to make your apps bigger or smaller based on how busy they are.To use it, you create a HorizontalPodAutoscaler file that tells Kubernetes which app you want to scale. Then, you use a command called kubectl to apply that file.Just remember, you can't use HorizontalPodAutoscaler with every type of app. For example, you can't use it with things like DaemonSets.</div><br/>
|
||||
|
||||
|
||||
<div className="text">To work properly, HPA needs a metrics server in your cluster. This server keeps track of important details like how much CPU and memory your apps are using. One popular option for this server is the Kubernetes Metrics Server.
|
||||
The metrics server is like an extra tool that adds more capabilities to the Kubernetes system. Basically, it works by gathering information about how much of your computer's resources, like CPU and memory, your apps are using. Then, it makes this information available to other parts of Kubernetes, like the Horizontal Pod Autoscaler.You can also use the metrics server with a command called kubectl top to check on how your apps are doing. This can be helpful for fixing any issues with autoscaling.</div><br/>
|
||||
|
||||
<div className="text">Be sure to take a look at the main documentation to understand why the metrics server is important.</div> <br/>
|
||||
|
||||
<div className="text">If you want to use metrics other than CPU or memory, like counting how many times your app is used, you can use something called Prometheus with a special adapter called prometheus-adapter. This lets you change the size of your apps based on these different metrics, not just how much CPU and memory they're using.</div> <br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>This guide will help you:</div>
|
||||
|
||||
<div className="text"><ol><li>Set up the Kubernetes Metrics Server in your DOKS cluster.</li><li>Learn the key ideas and how to make HPAs for your apps.</li><li>Test each HPA setup with two situations: when your app load stays the same, and when it changes.</li><li>Set up and use the Prometheus Adapter to change app sizes based on different metrics.</li></ol></div>
|
||||
|
||||
<div className="head">Before starting this tutorial, make sure you have:</div>
|
||||
|
||||
<div className="text"><ol><li>A Git client installed on your computer to download the Starter Kit repository.</li><li>Helm installed, which helps with managing Kubernetes Metrics Server installations and updates.</li><li>Kubectl installed for interacting with Kubernetes. Make sure it's set up and ready to use by following the instructions here to connect to your cluster.</li></ol></div>
|
||||
|
||||
<div className="text">Next, we'll show you how to deploy the Kubernetes Metrics Server using the Helm package manager.</div>
|
||||
|
||||
<div className="head">Setting Up the Kubernetes Metrics Server</div>
|
||||
|
||||
<div className="text"><ol><li>Using a single kubectl command, you can set up the Kubernetes Metrics Server in high availability mode.<br/><CodeBlock code={`kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/high-availability.yaml`} /><br/> </li><li>Alternatively, you can use Helm to deploy the metrics-server chart to your cluster.</li></ol></div>
|
||||
|
||||
<div className="text">In this tutorial, we're using the Helm installation method because it's more flexible. You can easily adjust settings later if needed, like making sure everything stays up and running smoothly.</div><br/>
|
||||
|
||||
<div className="text">Keep in mind, setting up the metrics server needs some special permissions. For all the details on what you need, take a look at the official requirements page.</div><br/>
|
||||
|
||||
<div className="text">Here's how to deploy the metrics server using Helm:</div>
|
||||
|
||||
<div className="text"><ol><li>Start by downloading the Starter Kit repository and open it on your computer. <br/><CodeBlock code={`git clone https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers.git
|
||||
cd Kubernetes-Starter-Kit-Developers
|
||||
`} /><br/> </li><li>Next, add the metrics-server Helm repository to your Helm configuration. Then, check the available charts. <br/> <CodeBlock code={`helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server
|
||||
helm repo update metrics-server
|
||||
helm search repo metrics-server
|
||||
`} /><br/></li><li>The result you see will look something like this: <br/><CodeBlock code={`OutputNAME CHART VERSION APP VERSION DESCRIPTION
|
||||
metrics-server/metrics-server 3.8.2 0.6.1 Metrics Server is a scalable, efficient source …
|
||||
`} /><br/></li><br/> <div className="note"><strong>Note</strong>: The chart we're interested in is called metrics-server/metrics-server. This will install the Kubernetes metrics server on your cluster. For more information, you can visit the metrics-server chart page. Next, open and take a look at the metrics-server Helm values file provided in the Starter Kit repository. You can use any text editor you like, but it's best if it supports YAML linting. For example, you can use VS Code.</div><br/><CodeBlock code={`code 07-scaling-application-workloads/assets/manifests/metrics-server-values-v3.8.2.yaml
|
||||
`} /><br/><li>Lastly, you'll install the Kubernetes Metrics Server using Helm. This will also create a special namespace just for the metrics-server.</li></ol></div>
|
||||
|
||||
<CodeBlock code={`HELM_CHART_VERSION="3.8.2
|
||||
helm install metrics-server metrics-server/metrics-server --version '$HELM_CHART_VERSION' \
|
||||
--namespace metrics-server \
|
||||
--create-namespace \
|
||||
--f "07-scaling-application-workloads/assets/manifests/metrics-server-values-v$ {HELM_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: We're using a specific version of the metrics-server Helm chart. In this case, we chose version 3.8.2, which corresponds to the 0.6.1 release of the metrics-server application (you can find this information in the output from Step 2). It's generally a good idea to specify a particular version like this. It helps ensure that your setup remains consistent and makes it easier to manage changes over time using tools like Git.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Deployment Status</div>
|
||||
<div className="text">You can check the status of the metrics-server deployment by</div>
|
||||
|
||||
<CodeBlock code={`helm ls -n metrics-server`} /><br/>
|
||||
|
||||
<div className="text">The result you see will look something like this (make sure to check that the STATUS column says "deployed"):-</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
metrics-server metrics-server 1 2022-02-24 14:58:23.785875 +0200 EET deployed metrics-server-3.8.2 0.6.1
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Next, take a look at the status of all the resources in the metrics-server namespace in Kubernetes:</div>
|
||||
|
||||
<CodeBlock code={`kubectl get all -n metrics-server`} /><br/>
|
||||
|
||||
<div className="text">The result will look something like this (make sure the deployment and replicaset resources are healthy, and there are two of each):</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME READY STATUS RESTARTS AGE
|
||||
pod/metrics-server-694d47d564-9sp5h 1/1 Running 0 8m54s
|
||||
pod/metrics-server-694d47d564-cc4m2 1/1 Running 0 8m54s
|
||||
|
||||
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
service/metrics-server ClusterIP 10.245.92.63 <none> 443/TCP 8m54s
|
||||
|
||||
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE
|
||||
deployment.apps/metrics-server 2/2 2 2 8m55s
|
||||
|
||||
|
||||
NAME DESIRED CURRENT READY AGE
|
||||
replicaset.apps/metrics-server-694d47d564 2 2 2 8m55s
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Lastly, let's see if the kubectl top command works. It's similar to the Linux top command, which shows the current usage of resources like CPU and memory. The command below will display the current resource usage for all Pods in the kube-system namespace:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`kubectl top pods -n kube-system`} /><br/>
|
||||
|
||||
<div className="text">The result you'll see will look something like this (CPU usage is shown in millicores, and memory usage is shown in Mebibytes):</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME CPU(cores) MEMORY(bytes)
|
||||
cilium-operator-5db58f5b89-7kptj 2m 35Mi
|
||||
cilium-r2n9t 4m 150Mi
|
||||
cilium-xlqkp 9m 180Mi
|
||||
coredns-85d9ccbb46-7xnkg 1m 21Mi
|
||||
coredns-85d9ccbb46-gxg6d 1m 20Mi
|
||||
csi-do-node-p6lq4 1m 19Mi
|
||||
csi-do-node-rxd6m 1m 21Mi
|
||||
do-node-agent-2z2bc 0m 15Mi
|
||||
do-node-agent-ppds8 0m 21Mi
|
||||
kube-proxy-l9ddv 1m 25Mi
|
||||
kube-proxy-t6c29 1m 30Mi
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">If you see a similar output as shown above, then you've set up the metrics server correctly. In the next step, we'll show you how to set up and test your first HorizontalPodAutoscaling resource.</div>
|
||||
|
||||
|
||||
<div className="head">Introduction to Horizontal Pod Autoscalers (HPAs)</div>
|
||||
|
||||
<div className="text">Up until now, whenever you made a new setup for your application in Kubernetes, you set a fixed number of copies for it to run. This might be okay for basic situations or when you're just testing things out. But now, let's talk about something called a Horizontal Pod Autoscaler (HPA) which can make things more flexible.</div><br/>
|
||||
|
||||
<div className="text">With an HPA, Kubernetes can automatically adjust the number of copies of your application based on how much it's being used. Think of it like this: if your app suddenly gets really popular and needs more copies to handle all the users, the HPA can make that happen without you having to manually change anything.</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: autoscaling/v2beta2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: my-app-hpa
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: my-app-deployment
|
||||
minReplicas: 1
|
||||
maxReplicas: 3
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 50
|
||||
`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Breaking Down the Configuration:</div>
|
||||
<div className="text"><ol><li>spec.scaleTargetRef: This tells Kubernetes what to keep an eye on and adjust. In our case, it's our deployment, my-app-deployment.</li><br/><li>spec.minReplicas: This is the smallest number of copies of our app that Kubernetes will keep running. We've set it to 1, so there's always at least one copy running, even if the app isn't busy.</li><br/><li>spec.maxReplicas: This is the largest number of copies Kubernetes will make. We've set it to 10, so even if lots of people start using our app, Kubernetes won't make too many copies and overload things</li><br/><li>spec.metrics.type: This tells Kubernetes what information to use when deciding if it needs to make more copies. In our example, we're using the "Resource" type, which means Kubernetes looks at things like how much CPU our app is using. If it goes over 50%, Kubernetes will make more copies to handle the extra load.</li></ol></div><br/>
|
||||
|
||||
<div className="text">Next, there are two ways you can set up an HPA for your application deployment:</div>
|
||||
|
||||
<div className="text"><ol><li>Using kubectl command: If you already have a deployment set up, you can use a command called kubectl autoscale to add an HPA to it.</li><li>Creating a YAML file: Alternatively, you can create a simple text file (called a YAML file) that describes your HPA settings. Then, you use another command, kubectl apply, to make those changes happen in your Kubernetes cluster.</li></ol></div>
|
||||
|
||||
|
||||
<div className="text">If you want to quickly test something without dealing with complex files, you can use the first option. Let's try it with an example from the Starter Kit.</div>
|
||||
|
||||
<div className="text"><ol><li>First, if you haven't already, you'll need to make a copy of the Starter Kit repository on your computer. Then, go to the folder where you saved it.<br/> <CodeBlock code={`git clone https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers.git
|
||||
cd Kubernetes-Starter-Kit-Developers
|
||||
`} /><br/></li><li>Next, let's create a deployment called "myapp-test". This deployment is meant to do something that uses up CPU, like printing a message over and over again without stopping.<br/><CodeBlock code={`kubectl apply -f https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers/blob/main/07-scaling-application-workloads/assets/manifests/hpa/metrics-server/myapp-test.yaml`} /><br/></li><li>Lastly, we'll make a Horizontal Pod Autoscaler (HPA) that focuses on our "myapp-test" deployment. This HPA helps adjust the number of copies of our app based on how much CPU it's using.<br/><CodeBlock code={`kubectl autoscale deployment myapp-test --cpu-percent=50 --min=1 --max=3`} /><br/></li></ol></div>
|
||||
|
||||
<div className="text">Here's what we're doing: We're asking Kubernetes to create something called an HPA for us. This HPA will keep an eye on our "myapp-test" deployment. When the average CPU usage of our app hits 50%, the HPA will automatically adjust the number of copies of our app. It won't make more than 3 copies, but it'll always keep at least 1 copy running. You can check if the HPA was created by running:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`kubectl get hpa`} /><br/>
|
||||
|
||||
<div className="text">Here's what you might see when you check if the HPA was created successfully: In the output, you'll notice a column labeled "TARGETS" which shows a value of 50%. This means that the HPA is set to keep the average CPU usage of our app at 50%. However, you might also see a higher number, like 240%, which represents the current CPU usage. This just means that our app is currently using more CPU than the target set by the HPA.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
|
||||
myapp-test Deployment/myapp-test 240%/50% 1 3 3 52s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Here's what you can expect: After creating the HPA, you might notice that for a short period, usually about 15 seconds, the "TARGETS" column will show "<unknown>/50%". This is completely normal. It just means that the HPA is gathering information about how much CPU our app is using and calculating the average over time. By default, the HPA checks these metrics every 15 seconds.</div>
|
||||
|
||||
<div className="text">If you want to see what's happening behind the scenes, you can check the events that the HPA generates by using:</div>
|
||||
|
||||
<CodeBlock code={`kubectl describe hpa myapp-test`} /><br/>
|
||||
|
||||
<div className="text">Here's what you might see in the output: Check out the list of events, and you'll notice something interesting. You'll see how the HPA is doing its job by automatically increasing the number of copies of our app.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputName: myapp-test
|
||||
Namespace: default
|
||||
Labels: <none>
|
||||
Annotations: <none>
|
||||
CreationTimestamp: Mon, 28 Feb 2022 10:10:50 +0200
|
||||
Reference: Deployment/myapp-test
|
||||
Metrics: ( current / target )
|
||||
resource cpu on pods (as a percentage of request): 240% (48m) / 50%
|
||||
Min replicas: 1
|
||||
Max replicas: 3
|
||||
Deployment pods: 3 current / 3 desired
|
||||
...
|
||||
Events:
|
||||
Type Reason Age From Message
|
||||
---- ------ ---- ---- -------
|
||||
Normal SuccessfulRescale 17s horizontal-pod-autoscaler New size: 2; reason: cpu resource utilization (percentage of request) above target
|
||||
Normal SuccessfulRescale 37s horizontal-pod-autoscaler New size: 3; reason: cpu resource utilization (percentage of request) above target
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">In a real-world situation, it's better to use a specific YAML file to create each HPA. This makes it easier to keep track of changes by saving the file in a Git repository. It also allows you to revisit the file later if you need to make any adjustments.</div>
|
||||
|
||||
<div className="text">Before we move on to the next step, let's remove the "myapp-test" deployment and the HPA that we created earlier. This will clean up our environment and get it ready for the next stage.</div>
|
||||
|
||||
<CodeBlock code={`kubectl delete hpa myapp-test
|
||||
kubectl delete deployment myapp-test
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Next, we're going to see how HPAs work in two different situations:</div>
|
||||
|
||||
<div className="text"><ol><li>Steady CPU Usage: Here, the application will be doing tasks that use up a lot of CPU power consistently.</li><li>Simulated Traffic: In this case, we'll pretend that there's a sudden surge of people using our application by sending a lot of requests to it over the internet. This will help us understand how the HPA reacts to increased demand.</li></ol></div>
|
||||
|
||||
<div className="head">Letting Apps Grow Automatically with Metrics Server</div>
|
||||
|
||||
<div className="text">During this step, we'll see how HPAs work in two scenarios:</div>
|
||||
<div className="text"><ol><li>Active Workload: We'll have an app that's consistently performing tasks that require a lot of computer power.</li><li>High Volume Usage: We'll simulate a scenario where many users are accessing our web app by sending it a high volume of rapid requests using a script.</li></ol></div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Scenario 1 - Keeping Busy with CPU-Intensive Tasks</div><br/>
|
||||
|
||||
<div className="text">In this scenario, we'll create a basic program using Python. This program will stay busy by doing tasks that require a lot of computer power. Below is the Python code:</div>
|
||||
|
||||
<CodeBlock code={`import math
|
||||
|
||||
while True:
|
||||
x = 0.0001
|
||||
for i in range(1000000):
|
||||
x = x + math.sqrt(x)
|
||||
print(x)
|
||||
print("OK!")
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">You can deploy the code using a file called "constant-load-deployment-test" from the Starter Kit repository. This file sets up everything needed for your program to run.</div>
|
||||
|
||||
<div className="text">To get started, first, you need to copy the Starter Kit repository to your computer. Then, go to the folder where you copied it.</div>
|
||||
|
||||
<CodeBlock code={`git clone https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers.git
|
||||
cd Kubernetes-Starter-Kit-Developers
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Next, let's create the deployment for our program using a command called "kubectl". We're also creating a separate area, called a "namespace", to make it easier to see what's happening.</div>
|
||||
|
||||
<CodeBlock code={`kubectl create ns hpa-constant-load
|
||||
kubectl apply -f https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers/blob/06eec522f859bba957297d3068341df089468e97/07-scaling-application-workloads/assets/manifests/hpa/metrics-server/constant-load-deployment-test.yaml -n hpa-constant-load
|
||||
`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: The deployment file included in this repository sets limits for the resources (like CPU and memory) that the sample application Pods can use. This is important because the HPA needs these limits to work properly. It's a good idea to set resource limits for all your application Pods to make sure they don't use up too much of your cluster's resources. </div>
|
||||
|
||||
<div className="text">Check to make sure that the deployment was created without any issues and that it's now running as expected.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get deployments -n hpa-constant-load`} /><br/>
|
||||
|
||||
<div className="text">Here's what you might see in the output: You'll notice that there's only one copy of the application running at the moment.</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME READY UP-TO-DATE AVAILABLE AGE
|
||||
constant-load-deployment-test 1/1 1 1 8s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After that, let's set up the "constant-load-hpa-test" resource in your cluster using the "kubectl" command.</div>
|
||||
|
||||
<CodeBlock code={`kubectl apply -f https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers/blob/main/07-scaling-application-workloads/assets/manifests/hpa/metrics-server/constant-load-hpa-test.yaml`} /><br/>
|
||||
|
||||
<div className="text">This command will make a HPA resource, which will keep an eye on the sample deployment we made earlier. You can check how the "constant-load-test" HPA is doing by using:</div>
|
||||
|
||||
<CodeBlock code={`kubectl get hpa constant-load-test -n hpa-constant-load`} /><br/>
|
||||
|
||||
|
||||
<div className="text">You'll see some details on the screen. Look for the part that says "REFERENCE". It shows that the HPA is keeping an eye on our "constant-load-deployment-test" deployment. Also, check out the "TARGETS" section. It tells us how much CPU our app is using.</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
|
||||
constant-load-test Deployment/constant-load-deployment-test 255%/50% 1 3 3 49s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">You may also notice in the above information that the number of copies of our sample app, shown in the "REPLICAS" column, went up from 1 to 3. This matches what we set in the HPA configuration. Since the app in our example quickly creates load, the whole process of scaling happened pretty fast.If you want to see more details about what the HPA did, you can check its events using the command: "kubectl describe hpa -n hpa-constant-load".</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Scenario 2 - Testing External Traffic</div>
|
||||
|
||||
<div className="text">In this scenario, we'll create a more realistic test where we simulate external users accessing our application. To do this, we'll use a different area, called a namespace, along with a set of files to observe how our application behaves separately from the previous test.</div>
|
||||
|
||||
<div className="text">You're going to test a sample server called "quote of the moment". When you send it an HTTP request, it sends back a different quote each time. To put pressure on the server, you'll send a lot of requests really quickly, about one every millisecond.</div>
|
||||
|
||||
<div className="text">To get started, you need to set up the "quote" deployment and service using a command called "kubectl". Before you do that, make sure you're in the right folder on your computer, called "Kubernetes-Starter-Kit-Developers.</div>
|
||||
|
||||
<CodeBlock code={`kubectl create ns hpa-external-load
|
||||
kubectl apply -f 07-scaling-application-workloads/assets/manifests/hpa/metrics-server/quote_deployment.yaml -n hpa-external-load`} /><br/>
|
||||
|
||||
<div className="text">Now, let's make sure that the quote application deployment and services are working correctly.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get all -n hpa-external-load`} /><br/>
|
||||
|
||||
<div className="text">Here's how the output might look:</div>
|
||||
<CodeBlock code={`OutputNAME READY STATUS RESTARTS AGE
|
||||
pod/quote-dffd65947-s56c9 1/1 Running 0 3m5s
|
||||
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
service/quote ClusterIP 10.245.170.194 <none> 80/TCP 3m5s
|
||||
|
||||
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE
|
||||
deployment.apps/quote 1/1 1 1 3m5s
|
||||
NAME DESIRED CURRENT READY AGE
|
||||
replicaset.apps/quote-6c8f564ff 1 1 1 3m5s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After that, let's set up the HPA for the quote deployment using the "kubectl" command:</div>
|
||||
|
||||
<CodeBlock code={`kubectl apply -f 07-scaling-application-workloads/assets/manifests/hpa/metrics-server/quote-deployment-hpa-test.yaml -n hpa-external-load`} /><br/>
|
||||
|
||||
<div className="text">Now, let's see if the HPA resource is set up and working correctly:</div>
|
||||
|
||||
<CodeBlock code={`kubectl get hpa external-load-test -n hpa-external-load`} /><br/>
|
||||
|
||||
<div className="text">Here's how the output might look:</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
|
||||
external-load-test Deployment/quote 1%/20% 1 3 1 108s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">In this case, it's important to note that we've set a different value for the CPU usage threshold, and we're also using a different approach to scale down. Here's how the configuration for the "external-load-test" HPA looks:</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: autoscaling/v2beta2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: external-load-test
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: quote
|
||||
behavior:
|
||||
scaleDown:
|
||||
stabilizationWindowSeconds: 60
|
||||
minReplicas: 1
|
||||
maxReplicas: 3
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 20
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">In this setup, we've changed how quickly the autoscaler reacts when scaling down, setting it to 60 seconds instead of the default 300 seconds. This isn't typically necessary, but it helps speed up the process for this specific test. Usually, the autoscaler waits for 5 minutes after scaling before making more changes. This helps prevent rapid changes and keeps things stable.</div>
|
||||
|
||||
<div className="text">In the last step, you'll use a script from this repository to put pressure on the target application, which is the quote server. This script quickly makes a bunch of HTTP requests, pretending to be users accessing the server. This helps simulate a lot of external activity, which is useful for demonstration purposes.</div>
|
||||
|
||||
<div className="text">Make sure to open two separate windows on your computer screen so you can see the results more clearly. You can use a tool like "tmux" for this.In the first window, run the script called "quote service load test". You can stop the script at any time by pressing Ctrl+C</div>
|
||||
|
||||
<CodeBlock code={`./quote_service_load_test.sh`} /><br/>
|
||||
|
||||
<div className="text">In another window, use the command "kubectl watch" with the "-w" flag to keep an eye on the Horizontal Pod Autoscaler (HPA) resource. This will let you see any changes to the HPA in real-time.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get hpa -n hpa-external-load -w`} /><br/>
|
||||
|
||||
<div className="text">Check out the animation below to see the results of the experiment:</div>
|
||||
|
||||
|
||||
|
||||
<!-- <images should add here > -->
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="text">Next, you'll discover how to adjust the size of your applications based on specific metrics from Prometheus. For instance, you can make your deployments bigger or smaller depending on how many times your application gets visited with HTTP requests, instead of just looking at how much CPU or memory it's using</div>
|
||||
|
||||
<div className="head">Automatically Scaling Applications with Prometheus: Beyond CPU Metrics</div>
|
||||
|
||||
<div className="text">In the previous steps, you learned how to make your applications bigger or smaller based on how much computer power they use (like CPU). But, you can also do this with other things, not just computer power. For example, you can use a tool called Prometheus to keep track of how many times people visit your website (like with HTTP requests). Then, you can tell your system to automatically adjust your website's size based on how many visitors it's getting. This way, if a lot of people are coming to your site, it can automatically become bigger to handle the traffic!</div><br/>
|
||||
|
||||
<div className="text">To do this, you'll need to set up something called the "prometheus-adapter." It's like a special tool that helps Prometheus talk to Kubernetes, which is the system managing your applications. The prometheus-adapter helps them understand each other better, like a translator between them.</div><br/>
|
||||
|
||||
<div className="text">If you want something quick and simple that uses less computer power, go for metrics-server. It gives you basic info like how much your computer's brain (CPU) and memory are working. But, if you need more detailed control and want to adjust your apps based on other things besides just CPU and memory, then choose Prometheus with the prometheus-adapter. It's like having a more advanced system that can handle a lot more information.</div><br/>
|
||||
|
||||
<div className="text">Before you start, make sure you have something called "Prometheus Operator" set up in your system. You also need to know a bit about "ServiceMonitors." If you don't have them set up yet, you can follow the instructions in the "Prometheus Monitoring Stack" chapter from the Starter Kit repository. Once that's ready, you need to create something called a "ServiceMonitor" to keep an eye on how your application is doing. This will send the information to the Kubernetes system through the prometheus-adapter. After that, the system can adjust your applications based on this information using something called the "horizontal pod auto scaler.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Simple Steps for Scaling Applications with Custom Metrics Using Prometheus</div>
|
||||
|
||||
<div className="text"><ol><li>Install the prometheus-adapter: First, you need to set up something called "prometheus-adapter" in your system.</li><br/><li>Tell Prometheus about your metrics: Then, you let Prometheus know what information to keep an eye on from your applications. We do this by creating something called "ServiceMonitors.</li><br/><li>Show your metrics to the system: After that, you tell the prometheus-adapter to share your application's custom metrics with the Kubernetes system. This is done by defining "discovery rules.</li><br/><li>Tell the system how to adjust: Lastly, you create something called an "HPA" (horizontal pod auto scaler) that focuses on your application. You configure it to change the size of your application based on the custom metrics you've set up.</li></ol></div>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Easy Install: Prometheus Adapter with Helm</div>
|
||||
<div className="text">You can install the Prometheus adapter using Helm, which is a tool that helps with managing software on your system. Here's how:</div>
|
||||
|
||||
<div className="text"><ol><li>First, copy the Starter Kit to your computer by using a command called "clone." Then, go to the folder where you put the Starter Kit on your computer.<br/> <CodeBlock code={`git clone https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers.git
|
||||
Kubernetes-Starter-Kit-Developers
|
||||
`} /><br/></li><li>Now, include the prometheus-community Helm repo on your system, and see what kinds of charts (software packages) are available.</li><CodeBlock code={`helm repo add prometheus-community https://prometheus-community.github.io/helm-chart
|
||||
helm repo update prometheus-community
|
||||
helm search repo prometheus-community
|
||||
`} /><br/>The result you see will be something like this: <br/><CodeBlock code={`OutputNAME CHART VERSION APP VERSION DESCRIPTION
|
||||
prometheus-community/alertmanager 0.18.0 v0.23.0 The Alertmanager handles alerts sent by client ...
|
||||
prometheus-community/kube-prometheus-stack 35.5.1 0.56.3 kube-prometheus-stack collects Kubernetes manif...
|
||||
prometheus-community/kube-state-metrics 4.9.2 2.5.1 Install kube-state-metrics to generate and expo...
|
||||
prometheus-community/prometheus 15.10.1 2.34.0 Prometheus is a monitoring system and time seri...
|
||||
prometheus-community/prometheus-adapter 3.3.1 v0.9.1 A Helm chart for k8s prometheus adapter
|
||||
…
|
||||
`} /><br/><li>The chart we're interested in is called "prometheus-adapter." This is the one that will set up prometheus-adapter on your system. You can find more information about it on the prometheus-adapter chart page.Next, open the prometheus-adapter Helm values file from the Starter Kit repository using a text editor. It's best to use one that supports YAML linting. For example, you can use VS Code.<br/><CodeBlock code={`code https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers/blob/main/07-scaling-application-workloads/assets/manifests/prometheus-adapter-values-v3.3.1.yaml`} /><br/></li><li>Be sure to change the Prometheus endpoint setting according to your setup, and the instructions are there in the Helm values file.</li><li>Once you've made the necessary changes, save the file. Now, install a prometheus-adapter using Helm. It will also create a special space for the prometheus-adapter called a "namespace.</li></ol></div>
|
||||
|
||||
<CodeBlock code={`HELM_CHART_VERSION="3.3.1"
|
||||
helm install prometheus-adapter prometheus-community/prometheus-adapter \
|
||||
--version "$ HELM_CHART_VERSION" \
|
||||
--namespace prometheus-adapter \
|
||||
--create-namespace \
|
||||
-f "07-scaling-application-workloads/assets/manifests/prometheus-adapter-values-v$ {HELM_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">We're using a particular version of the prometheus-adapter Helm chart, specifically version 3.3.1. This version matches with the 0.9.1 release of the Prometheus-adapter application (you can find this information in the output from Step 2).Choosing a specific version is a good idea because it gives us control and predictability. It helps ensure that we get the expected results, and it's easier to manage different versions using tools like Git.</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Evaluating Setup: What to Look For</div>
|
||||
|
||||
<div className="text">Check to see if prometheus-adapter has been successfully set up by:</div>
|
||||
|
||||
<CodeBlock code={`helm ls -n prometheus-adapter`} /><br/>
|
||||
|
||||
<div className="text">The result you want to see will look something like this (pay attention to the word "deployed" in the STATUS column):</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
prometheus-adapter prometheus-adapter 1 2022-03-01 12:06:22 deployed prometheus-adapter-3.3.1 v0.9.1
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, take a look at the status of the resources in the special space we created for the prometheus-adapter, called the "prometheus-adapter namespace.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get all -n prometheus-adapter`} /><br/>
|
||||
|
||||
<div className="text">The result you're aiming for will resemble this (pay attention to the deployment and replicaset resources, they should be in good health and the count should be 2):</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME READY STATUS RESTARTS AGE
|
||||
pod/prometheus-adapter-7f475b958b-fd9sm 1/1 Running 0 2m54s
|
||||
pod/prometheus-adapter-7f475b958b-plzbw 1/1 Running 0 2m54s
|
||||
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
service/prometheus-adapter ClusterIP 10.245.150.99 <none> 443/TCP 2m55s
|
||||
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE
|
||||
deployment.apps/prometheus-adapter 2/2 2 2 2m55s
|
||||
|
||||
NAME DESIRED CURRENT READY AGE
|
||||
replicaset.apps/prometheus-adapter-7f475b958b 2 2 2 2m55s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Wait for a little bit and then ask the system for information using something called the "custom.metrics.k8s.io API." Save the answers to a file</div>
|
||||
|
||||
<CodeBlock code={`kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 > custom_metrics_k8s_io.json`} /> <br/>
|
||||
|
||||
<div className="text">Open the file named "custom_metrics_k8s_io.json," and you'll see information about special metrics that the Kubernetes system is sharing.</div>
|
||||
|
||||
<CodeBlock code={`{
|
||||
"kind": "APIResourceList",
|
||||
"apiVersion": "v1",
|
||||
"groupVersion": "custom.metrics.k8s.io/v1beta1",
|
||||
"resources": [
|
||||
{
|
||||
"name": "jobs.batch/prometheus_sd_kubernetes_events",
|
||||
"singularName": "",
|
||||
"namespaced": true,
|
||||
"kind": "MetricValueList",
|
||||
"verbs": [
|
||||
"get"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "services/kube_statefulset_labels",
|
||||
"singularName": "",
|
||||
"namespaced": true,
|
||||
"kind": "MetricValueList",
|
||||
"verbs": [
|
||||
"get"
|
||||
]
|
||||
},
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">If what you see matches the example above, it means you've set up the prometheus-adapter correctly. Now, let's move on to the next step where you'll discover how to create a simple application. This application will have its own special metrics, and we'll make sure Prometheus knows how to keep an eye on them by setting up something called a "ServiceMonitor.</div>
|
||||
|
||||
|
||||
<div className="head">Setting Up a Practice Application with Prometheus Example Metrics</div>
|
||||
|
||||
<div className="text">Let's set up a practice application to see if our system is working correctly. We're going to use an example application called "prometheus-example," and it gives us information about how our website is doing. Here are the things it will tell us:</div>
|
||||
|
||||
<div className="text">Total incoming requests:</div>
|
||||
<div className="text"> a. Metric: http_requests_total</div>
|
||||
<div className="text"> b. What it tells us: The overall number of people coming to our website.</div> <br/>
|
||||
|
||||
<div className="text">Duration of all requests:</div>
|
||||
<div className="text"> a. Metric: http_request_duration_seconds</div>
|
||||
<div className="text"> b. What it tells us: How long, on average, people spend on our website.</div><br/>
|
||||
|
||||
<div className="text">Total count of all requests:</div>
|
||||
<div className="text"> a. Metric: http_request_duration_seconds_count</div>
|
||||
<div className="text"> b. What it tells us: The total number of all visits to our website</div><br/>
|
||||
|
||||
<div className="text">Total duration of all requests</div>
|
||||
<div className="text"> a. Metric: http_request_duration_seconds_sum </div>
|
||||
<div className="text"> b. What it tells us: The combined time, in seconds, everyone spends on our website.</div><br/>
|
||||
|
||||
|
||||
<div className="text">Histogram of request durations:</div>
|
||||
<div className="text"> a. Metric: http_request_duration_seconds_bucke</div>
|
||||
<div className="text"> b. What it tells us: A fancy way of showing the range of time people spend on our website. </div><br/>
|
||||
|
||||
|
||||
<div className="text">This will help us test if our system is set up correctly.</div>
|
||||
|
||||
<div className="text">Once you've deployed the prometheus-example application, you'll want to test out how the automatic scaling works with custom metrics. To do this, you'll need to send a bunch of requests to the prometheus-example service and see how it responds by adjusting its size based on the number of requests.</div>
|
||||
|
||||
<div className="text">Before you do that, make sure you're in the right folder on your computer where you copied the Starter Kit.</div>
|
||||
|
||||
<CodeBlock code={`cd Kubernetes-Starter-Kit-Developers`} /><br/>
|
||||
|
||||
<div className="text">Next, let's put the prometheus-example application into action. You can do this by using a special set of instructions written in a file called a "YAML manifest" from the Starter Kit. This file will tell your system to create the prometheus-example application along with some other necessary things, like a service. It also sets up a special area, known as a "namespace," called prometheus-custom-metrics-test, just to make sure everything is working smoothly.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`kubectl create ns prometheus-custom-metrics-test
|
||||
kubectl apply -f 07-scaling-application-workloads/assets/manifests/hpa/prometheus-adapter/prometheus-example-deployment.yaml -n prometheus-custom-metrics-test
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After you've set up the prometheus-example application, double-check to make sure everything was created correctly in the special area we made called "prometheus-custom-metrics-test namespace.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get all -n prometheus-custom-metrics-test`} /><br/>
|
||||
|
||||
<div className="text">You'll see something like this in the results (make sure the "prometheus-example-app" is listed and marked as "up and running," along with the associated service).</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME READY STATUS RESTARTS AGE
|
||||
pod/prometheus-example-app-7455d5c48f-wbshc 1/1 Running 0 9s
|
||||
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
service/prometheus-example-app ClusterIP 10.245.103.235 <none> 80/TCP 10s
|
||||
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE
|
||||
deployment.apps/prometheus-example-app 1/1 1 1 10s
|
||||
|
||||
NAME DESIRED CURRENT READY AGE
|
||||
replicaset.apps/prometheus-example-app-7455d5c48f 1 1 1 10s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Preparing Prometheus for Application Monitoring</div>
|
||||
|
||||
<div className="text">Before we set up something called a "ServiceMonitor" for our application, let's make sure our Prometheus system is ready for it. Follow these steps:</div>
|
||||
|
||||
<div className="text"><ol><li>Start by finding out which Prometheus instances are in your system. The Starter Kit uses a place called the "monitoring namespace," but you might need to adjust this based on how your system is set up. <br/> <CodeBlock code={`kubectl get prometheus -n monitoring`} /><br/> The result you'll see will look something like this: <br/> <CodeBlock code={`OutputNAME VERSION REPLICAS AGE
|
||||
kube-prom-stack-kube-prome-prometheus v2.35.0 1 7h4m
|
||||
`} /><br/></li><li>Now, choose the Prometheus instance you found in the last step (if there's more than one, select the one that matches your setup). Look for something called "serviceMonitorSelector.matchLabels" and note down its value.<br/><CodeBlock code={`kubectl get prometheus kube-prom-stack-kube-prome-prometheus -n monitoring -o jsonpath='{.spec.serviceMonitorSelector.matchLabels}'`} /><br/></li></ol></div>
|
||||
|
||||
|
||||
<div className="text">You'll see something like this in the results (keep an eye out for a label called "release").</div>
|
||||
|
||||
<CodeBlock code={`{"release":"kube-prom-stack"}`} /><br/>
|
||||
|
||||
<div className="text">By default, each Prometheus instance is set up to find only service monitors that have a certain label. To make sure our prometheus-example-app ServiceMonitor gets noticed by Prometheus, we need to give it a label called "release" with the value "kube-prom-stack."</div>
|
||||
|
||||
<div className="text">Before you do anything else, make sure you're in the right folder on your computer where you copied the Starter Kit.</div>
|
||||
|
||||
<CodeBlock code={`cd Kubernetes-Starter-Kit-Developers`} /><br/>
|
||||
|
||||
<div className="text">Next, take a look at a file called "prometheus-example-service-monitor" from the Starter Kit on your computer. You can use a program like VS Code, which is a good choice because it helps with checking if everything is written correctly in this special file called YAML.</div>
|
||||
|
||||
<CodeBlock code={`code 07-scaling-application-workloads/assets/manifests/hpa/prometheus-adapter/prometheus-example-service-monitor.yaml`} /><br/>
|
||||
|
||||
<div className="text">In the part of the file that talks about "metadata.labels," make sure to include the label we found earlier (it's called "release" and should have the value "kube-prom-stack"). The ServiceMonitor file will look something like this:</div>
|
||||
|
||||
<CodeBlock code={`kind: ServiceMonitor
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
metadata:
|
||||
name: prometheus-example-app
|
||||
labels:
|
||||
app: prometheus-example-app
|
||||
release: kube-prom-stack
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: prometheus-example-app
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- prometheus-custom-metrics-test
|
||||
endpoints:
|
||||
- port: web
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Last step! Let's make the ServiceMonitor we need. This ServiceMonitor will tell Prometheus to keep an eye on the /metrics information from our prometheus-example-app.</div>
|
||||
|
||||
<CodeBlock code={`kubectl apply -f 07-scaling-application-workloads/assets/manifests/hpa/prometheus-adapter/prometheus-example-service-monitor.yaml -n prometheus-custom-metrics-test`} /><br/>
|
||||
|
||||
<div className="text">Once you've finished the steps above, you'll notice a new item in the Targets panel on the Prometheus dashboard. To view this dashboard, you need to use a command to make it accessible. Here's an example command using the Starter Kit naming conventions. Please adjust it based on how your system is set up:</div>
|
||||
|
||||
<CodeBlock code={`kubectl port-forward svc/kube-prom-stack-kube-prome-prometheus 9090:9090 -n monitoring`} /><br/>
|
||||
|
||||
<div className="text">The result you'll see looks something like this (look for "prometheus-example-app" in the list of discovered targets):</div>
|
||||
|
||||
|
||||
|
||||
<!-- <need to add image here > -->
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="text">Open a web browser and go to "localhost:9090". Then, click on "Status" and choose "Targets". You'll see that the target we added has been included.</div>
|
||||
|
||||
|
||||
<div className="head">Enabling Kubernetes Access to Custom Metrics with Prometheus Adapter</div>
|
||||
|
||||
<div className="text">Even though Prometheus can find and gather data about your application's special metrics, the prometheus-adapter needs some help to share these metrics with Kubernetes. To make this happen, you have to set up a few rules called "discovery rules." These rules will guide the prometheus-adapter in exposing your application's custom metrics.</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Quoting from the official guide:</div>
|
||||
<div className="text">The adapter decides which metrics to show and how to show them using a set of "discovery" rules. Each rule works on its own (so they shouldn't overlap), and it outlines the steps for the adapter to expose a metric in the API.</div>
|
||||
|
||||
<div className="text">Each rule has roughly four parts:</div>
|
||||
<div className="text"><ol><li>Discovery: <ul><li>How the adapter should find all Prometheus metrics for this rule.</li></ul></li><li>Association:<ul><li>How the adapter should figure out which Kubernetes resources a specific metric is related to.</li></ul></li><li>Naming: <ul><li>How the adapter should display the metric in the custom metrics API.</li></ul></li><li>Querying: <ul><li>How a request for a certain metric on one or more Kubernetes objects should be translated into a question to Prometheus.</li></ul></li></ol></div>
|
||||
|
||||
<div className="text">A regular definition for a discovery rule looks something like this:</div>
|
||||
|
||||
<CodeBlock code={`rules:
|
||||
custom:
|
||||
- seriesQuery: 'http_requests_total{pod!=""}'
|
||||
resources:
|
||||
template: "<<.Resource>>"
|
||||
name:
|
||||
matches: "^(.*)_total"
|
||||
as: "${1}_per_second"
|
||||
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>}[2m])) by (<<.GroupBy>>)"
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Let's break down the configuration into simpler parts:</div>
|
||||
|
||||
<div className="text"><ol><li>seriesQuery:<ul><li>This part represents the metric you want to track, like the total number of HTTP requests shown by the application's /metrics endpoint. It tells the prometheus-adapter to choose the http_requests_total metric for all your application Pods that are not null (pod!=""). This is like telling it what to look for.</li></ul></li><li>resources.template:<ul><li>Think of this as a template that Prometheus uses to understand where the metrics are coming from (like from a Pod). This part helps the prometheus-adapter figure out the resource that exposes the metrics (e.g., Pod). It's like connecting the metric to the thing it's related to.</li></ul></li><li>name: <ul><li>Here, you're giving a new name to the rule. In simple terms, you're telling the prometheus-adapter to rename http_requests_total to http_requests_per_second. Essentially, you're saying you're interested in the number of HTTP requests per second, not just a simple count. This is about making the metric name more meaningful.</li></ul></li><li>metricsQuery: <ul><li>This is a fancy term for a parameterized query in Prometheus language (PromQL). It's like a way of asking Prometheus for information. In this case, it calculates the rate of HTTP requests on average over a set period (like 2 minutes). It's the way of telling the prometheus-adapter how to interpret the metric.</li></ul></li></ol></div>
|
||||
|
||||
|
||||
<div className="text">Now that you've learned how to create discovery rules for prometheus-adapter, let's apply this knowledge. Follow these simple steps to tell prometheus-adapter to use the rules you've just set up:</div>
|
||||
|
||||
<CodeBlock code={`cd Kubernetes-Starter-Kit-Developers`} /><br/>
|
||||
|
||||
<div className="text"><ol><li>Start by making sure you're in the right folder on your computer where you copied the Starter Kit. <br/> <CodeBlock code={`cd Kubernetes-Starter-Kit-Developers`} /><br/> </li><li>After that, open a file called "prometheus-adapter Helm values" from the Starter Kit on your computer. You can use a program like VS Code, which is a good choice because it helps check if everything is written correctly in this special file called YAML. <br/> <CodeBlock code={`code https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers/blob/main/07-scaling-application-workloads/assets/manifests/prometheus-adapter-values-v3.3.1.yaml`} /><br/></li><li>Find a part in the file called "rules," and remove the commenting symbols (usually hashtags or double slashes) from the beginning of the lines. When you're done, it should look something like this <br/><CodeBlock code={``} /><br/></li><li>First, keep a file where we list all the settings we want to use. Then, when we want to make changes to our project, we use Helm to update it with these new settings.<br/><CodeBlock code={`HELM_CHART_VERSION="3.3.1"
|
||||
helm upgrade prometheus-adapter prometheus-community/prometheus-adapter \
|
||||
--version "$ HELM_CHART_VERSION" \
|
||||
--namespace prometheus-adapter \
|
||||
-f "07-scaling-application-workloads/assets/manifests/prometheus-adapter-values-v$ {HELM_CHART_VERSION}.yaml"
|
||||
`} /><br/> </li></ol></div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: When there aren't any requests coming in, we only see the version metric. To start seeing more metrics, like how many times our website is visited, we need to do something: generate some HTTP requests. This means we need to simulate people visiting our website by sending requests to it.</div>
|
||||
|
||||
<CodeBlock code={`kubectl port-forward svc/prometheus-example-app 8080:8080 -n prometheus-custom-metrics-test`} /><br/>
|
||||
|
||||
<div className="text">Open a web browser and go to http://localhost:8080. Then, just refresh the homepage of the application a few times.</div>
|
||||
|
||||
<div className="text">If everything's working correctly, you'll be able to check a new metric by using the custom metrics API. To make it easier to read the results, you can install a tool called jq.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get --raw="/apis/custom.metrics.k8s.io/v1beta1/namespaces/prometheus-custom-metrics-test/pods/*/http_requests_per_second" | jq .`} /><br/>
|
||||
|
||||
<div className="text">The result you see might look something like this:</div>
|
||||
|
||||
<CodeBlock code={`{
|
||||
"kind": "MetricValueList",
|
||||
"apiVersion": "custom.metrics.k8s.io/v1beta1",
|
||||
"metadata": {
|
||||
"selfLink": "/apis/custom.metrics.k8s.io/v1beta1/namespaces/prometheus-custom-metrics-test/pods/%2A/http_requests_per_second"
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"describedObject": {
|
||||
"kind": "Pod",
|
||||
"namespace": "prometheus-custom-metrics-test",
|
||||
"name": "prometheus-example-app-7455d5c48f-wbshc",
|
||||
"apiVersion": "/v1"
|
||||
},
|
||||
"metricName": "http_requests_per_second",
|
||||
"timestamp": "2022-03-02T13:33:32Z",
|
||||
"value": "0",
|
||||
"selector": null
|
||||
}
|
||||
]
|
||||
}
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">When you look at the output above, you'll see a metric called http_requests_per_second with a value of 0. This is expected because we haven't put any pressure on the application yet.</div>
|
||||
|
||||
<div className="text">Now, for the last step, we'll set up something called HPA for the deployment of our application. Then, we'll create some activity on the application using a script called custom_metrics_service_load_test, which you can find in the Starter Kit repository.</div>
|
||||
|
||||
<div className="head">Setting Up and Testing HPAs with Custom Metrics</div>
|
||||
<div className="text">Creating and testing HPAs (Horizontal Pod Autoscalers) with custom metrics is pretty much like what we did with the metrics server examples. The only thing that changes is how we measure the application's performance, which in this case uses custom metrics like http_requests_per_second.</div>
|
||||
|
||||
<div className="text">A typical HPA definition based on custom metrics looks something like this (important fields are explained as we go along):</div>
|
||||
|
||||
<CodeBlock code={`kind: HorizontalPodAutoscaler
|
||||
apiVersion: autoscaling/v2beta2
|
||||
metadata:
|
||||
name: prometheus-example-app
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: prometheus-example-app
|
||||
minReplicas: 1
|
||||
maxReplicas: 5
|
||||
metrics:
|
||||
# use a "Pods" metric, which takes the average of the
|
||||
# given metric across all pods controlled by the autoscaling target
|
||||
- type: Pods
|
||||
pods:
|
||||
metricName: http_requests_per_second
|
||||
# target 500 milli-requests per second,
|
||||
# which is 1 request every two seconds
|
||||
targetAverageValue: 500m
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">First, go to the folder where you saved the Starter Kit on your computer:</div>
|
||||
<CodeBlock code={`cd Kubernetes-Starter-Kit-Developers`} /><br/>
|
||||
|
||||
<div className="text">Next, set up the prometheus-custom-metrics-hpa resource in your cluster by using kubectl:</div>
|
||||
|
||||
<CodeBlock code={`kubectl apply -f https://github.com/digitalocean/Kubernetes-Starter-Kit-Developers/blob/06eec522f859bba957297d3068341df089468e97/07-scaling-application-workloads/assets/manifests/hpa/prometheus-adapter/prometheus-custom-metrics-hpa.yaml`} /><br/>
|
||||
|
||||
<div className="text">The command above creates something called an HPA, which stands for Horizontal Pod Autoscaler. It's set up to watch over the sample deployment we made earlier. You can see how the HPA is doing by using:</div>
|
||||
|
||||
<CodeBlock code={`kubectl get hpa -n prometheus-custom-metrics-test`} /><br/>
|
||||
|
||||
<div className="text">The result you'll see looks something like this (pay attention to the REFERENCE column, which points to the prometheus-example-app deployment, and the TARGETS column, showing the current number of http_requests_per_second):</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
|
||||
prometheus-custom-metrics Deployment/prometheus-example-app 0/500m 1 5 1 19s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">In the last step, you'll use a script provided in this repository to put some pressure on the target (which is the Prometheus-example-app). This script will make a bunch of quick HTTP requests, acting like multiple users accessing the app simultaneously (it's enough for showing how things work).</div>
|
||||
|
||||
<div className="text">To make it easier to see what's happening, it's best to split your screen into two separate windows. You can do this with a tool like tmux. Then, in the first window, you'll run a script called custom_metrics_service_load_test. You can stop it anytime by pressing Ctrl+C.</div>
|
||||
|
||||
<CodeBlock code={`./custom_metrics_service_load_test.sh`} /><br/>
|
||||
|
||||
<div className="text">Next, in the second window, you'll want to keep an eye on what's happening with the HPA resource. To do this, you can use a command called kubectl watch with the -w flag. This command will continuously show you updates in real-time.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get hpa -n prometheus-custom-metrics-test -w`} /><br/>
|
||||
|
||||
|
||||
<!-- <image needs to add here > -->
|
||||
|
||||
|
||||
|
||||
<div className="text">You can watch as the autoscaler starts working when the load increases (while the load generator script is running). It'll increase the number of replicas for the prometheus-example-app deployment. Once you stop the load generator script, there's a waiting period, and after about 5 minutes, the number of replicas goes back to the original value of 1.</div>
|
||||
|
||||
|
||||
<div className="head">Highlighted Phases:</div>
|
||||
|
||||
<div className="text">Phase 1: This is when things are ramping up. You'll see the HPA gradually increasing the number of replicas from 1 to 8 as the initial load increases from around 2140 milli-requests per second to a more manageable 620 milli-requests per second with more Pods added.</div>
|
||||
|
||||
<div className="text">Phase 2: Things start to stabilize here. The current load has small ups and downs, staying between 520-540 milli-requests per second.</div>
|
||||
|
||||
<div className="text">Phase 3: In this phase, there's a sudden increase in load, going over 10% of the threshold value to 562 milli-requests per second. Since we're out of the hysteresis window, the HPA adds more replicas (9) to stabilize the system. This quickly brings the load back down to around 480 milli-requests per second.</div>
|
||||
|
||||
<div className="text">Phase 4: Here, we stop the load generator script. You'll see the application's load decrease rapidly. After about 5 minutes (the default cooldown time), the number of replicas goes back to the minimum value of 1.</div>
|
||||
|
||||
<div className="text">Let's say we want to keep the number of HTTP requests close to a certain limit, like our threshold. The HPA won't keep increasing the number of replicas if the average number of requests is already close to the threshold (let's say within ± 10%). Even if we haven't hit the upper limit yet, this helps prevent constant changes in the number of replicas. This idea is called hysteresis. It's like a stabilizing factor that helps avoid bouncing back and forth between different replica counts. Hysteresis is important because it keeps systems more stable, preventing constant ups and downs.</div><br/>
|
||||
|
||||
<div className="con">Conclusion</div>
|
||||
|
||||
<div className="text">In this guide, you discovered how to make your application adjust its size based on its needs. We used some tools to measure this, like metrics-server and Prometheus.You also got to see how this works in real life. The HPAs automatically change your application's size to handle more visitors or traffic, keeping everything running smoothly.</div>
|
||||
|
||||
<div className="text"><strong>Excited to try it out? Give it a go with your own applications and see how it works!</strong></div>
|
||||
992
blog/2019-05-29-blog-7.md
Normal file
@ -0,0 +1,992 @@
|
||||
---
|
||||
slug: Using Flux CD for Easier GitOps
|
||||
title: Using Flux CD for Easier GitOps
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
<div className="head">Welcome to this guide! Here, you'll discover how to:</div>
|
||||
<div className="text"><ol><li>Set up a Flux CD on your DOKS cluster using the flux CLI.</li><li>Keep your Kubernetes cluster apps in sync with a Git repository (using GitOps principles).</li><li>Install and handle applications using Flux CD HelmReleases.</li><li>Set up and manage the Sealed Secrets controller with Flux CD to secure important information.</li></ol></div><br/>
|
||||
|
||||
<div className="text">Let's make your journey into these concepts easy and enjoyable!</div>
|
||||
<div className="text">Once you've followed all the steps in this guide, your DOKS cluster will be equipped with Flux CD. Here's what it will do:</div>
|
||||
|
||||
<div className="text"><ol><li>Keep things in sync: Flux CD will make sure your cluster stays updated by looking at the instructions in your GitRepository.</li><li>Manage applications smoothly: It will handle Helm releases effortlessly, paying attention to the details outlined in your HelmRelease.</li></ol></div><br/>
|
||||
|
||||
<div className="text">In simpler terms, your DOKS cluster will be smartly organized and will always know what's happening thanks to Flux CD!</div><br/>
|
||||
|
||||
<div className="text">Flux CD is like a helpful guide for your computer setup. It makes sure everything in your system is up-to-date by checking a special place called Git. Think of Git as a master plan for your computer.With Flux CD, you can easily update and deliver your apps without any hassle. It's like having a smart assistant that knows how to take care of everything. It even understands the language of Kubernetes, which is like a super tool for managing computer programs.So, with Flux CD, your computer stays organized and you can control how your apps get installed and updated in a smooth and easy way!</div><br/>
|
||||
|
||||
<div className="text">Flux CD helps keep your computer organized by making sure everything is in the right place. This process is called reconciliation. It's like having a team of helpers that regularly checks your computer to match it with a special plan you've set up somewhere, like in a special folder (Git), a magic box (Helm or S3). In simpler terms, reconciliation is the way these helpers ensure your computer is always the way you want it to be – neat and tidy!</div><br/>
|
||||
|
||||
<div className="text">Flux CD gives you different tools to make sure your computer stays organized. Here are three ways it does that:</div>
|
||||
|
||||
|
||||
<div className="text"><ol><li>HelmRelease: Helps in checking and updating your computer's state using something called Helm releases.</li><li>Bucket: Assists in checking and updating your computer by looking at things stored in a special place called a bucket.</li><li>Kustomization: Uses a set of instructions to organize your computer, stored in a special folder (Git) or a specific storage location (S3 bucket).</li></ol></div><br/>
|
||||
|
||||
|
||||
<div className="text">In simpler terms, Flux CD offers various tools to make sure your computer stays organized and follows the plans you've set for it!</div>
|
||||
|
||||
<div className="text">Flux CD uses special helpers called controllers. Each controller has a specific job:</div>
|
||||
|
||||
<div className="text"><ol><li>Source Controller: Manages where you keep your plans, like Git, Helm, or a storage place. It fetches instructions to make sure your computer does what you want.</li><li>Helm Controller: Handles special updates for your computer known as Helm releases.</li><li>Kustomize Controller: Follows a set of rules for organizing your computer, ensuring it follows instructions stored in a special folder or storage place.</li></ol></div><br/>
|
||||
|
||||
<div className="text">In simpler terms, these controllers work behind the scenes to keep everything organized and make sure your computer follows your plans!</div><br/>
|
||||
|
||||
<div className="text">Flux CD has a special tool called Source CRD (Custom Resource Definition). Think of it like a helper that grabs important information for your computer.This tool acts like a messenger – it goes to special places, like Git, Helm or a storage area, and brings back the instructions for how your computer should be set up. So, the Source CRD helps Flux get all the necessary details to keep your computer in the right state!</div><br/>
|
||||
|
||||
<div className="text">The Starter Kit uses a special tool called a Git repository to keep track of how your applications should be. It also uses something called HelmReleases to help with putting your applications on your computer.</div><br/>
|
||||
|
||||
<div className="text">Now, when it comes to keeping an eye on how your computer is doing, Flux CD has a friend called the Notification Controller. This friend can send you messages on platforms like Slack, Discord, or Microsoft Teams to let you know what's happening. It's like having a buddy who keeps you informed!</div><br/>
|
||||
|
||||
<div className="text">For watching over the overall health of your computer, Flux CD supports tools like Prometheus (official guide) and Loki. They're like doctors who check your computer to make sure everything is working smoothly!</div><br/>
|
||||
|
||||
<div className="head">Requirements:</div>
|
||||
|
||||
<div className="text">Before we start, make sure you have the following:</div>
|
||||
<div className="text"><ol><li>A ready-to-go DOKS cluster: Think of this as your team of computer helpers. Follow the Starter Kit DOKS Setup Guide to get it set up.</li><li>A special place on the internet: This is like a digital notebook (GitHub repository and branch). It's where we'll keep important information for Flux CD and your computer programs.</li><li>A copying tool for the internet: We'll need a Git client to grab some helpful information. It's like a digital copy-paste tool.</li><li>A talking tool for your DOKS cluster: This is called Kubectl CLI. It helps you talk to your DOKS cluster, telling it what to do. Follow some simple instructions to connect it.</li><li>A special helper for Flux CD: Flux CLI is like a magic wand. It helps us deploy and talk to Flux CD, our smart assistant for computer programs.</li><li>A secret keeper: Kubeseal is a tool for keeping secrets safe. It helps us lock away important information, and it's friends with the Sealed Secrets Controller.</li></ol></div>
|
||||
|
||||
<div className="text">With these tools, you'll be all set to make your computer do amazing things!</div>
|
||||
|
||||
|
||||
<div className="head">Exploring Flux CD: Making Helm Releases Super Easy</div><br/>
|
||||
|
||||
<div className="text">Flux CD efficiently manages Helm releases, acting as a guide for setting up applications on your computer. It utilizes HelmRelease to understand and handle these instructions. Every HelmRelease relies on HelmRepository, a companion in this process. HelmRepository serves as a resource where Flux CD accesses specific guides, known as Helm charts, to install your applications. Think of HelmRepository as the place where Flux CD finds the instructions to make your apps work on your computer!</div><br/>
|
||||
|
||||
<div className="text">Now that you've tried installing things with Helm using commands (like in the Starter Kit), Flux CD has a similar way of doing it through its Helm Controller. Instead of typing commands, you create special instructions (manifests) using some codes like CRDs (HelmRepository, HelmRelease). These codes tell the Helm Controller to do the same tasks as the commands you used before (like 'helm install' or 'helm upgrade'). It's like giving Flux CD a set of rules to follow for installing and updating things on your computer!</div>
|
||||
|
||||
<div className="head">Setting Up Special Places for Flux CD with HelmRepository</div><br/>
|
||||
<div className="text">Flux CD uses something called HelmRepository to deal with Helm repositories. It's like a helper that goes to a special place on the internet to bring back the charts needed for your computer. You can think of HelmRepository as a set of instructions you give to Flux CD. These instructions are like telling Flux CD, "Hey, go to this specific place online and grab the charts we need." It's a simple way of making sure Flux CD knows where to find the important stuff for your computer!</div><br/>
|
||||
|
||||
<div className="text">Here's what a HelmRepository setup usually looks like:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`apiVersion: source.toolkit.fluxcd.io/v1beta1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: ambassador
|
||||
namespace: flux-system
|
||||
spec:
|
||||
interval: 10m0s
|
||||
url: https://app.getambassador.io
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Let's break down what each part means:</div>
|
||||
|
||||
<div className="text"><ol><li><kind>: This tells Flux CD what type of setup we're using (like HelmRepository in the example).</li><li><metadata.name>: It's the name you give to this HelmRepository setup (like 'ambassador' in the example).</li><li><metadata.namespace>: Think of it as a special area for this HelmRepository (like 'flux-system' in the example).</li><li><spec.interval>: This is like setting how often Flux CD should check for new things from the place we're getting our charts (similar to saying 'helm repo update' in the command line).</li><li><spec.url>: It's the web address where Flux CD can find the charts we want to use for our computer.</li></ol></div>
|
||||
|
||||
<div className="text">So, in simple terms, it's like giving a Flux CD a note saying what type of setup, the name, the special area, how often to check, and where to find the charts.</div>
|
||||
|
||||
<div className="head">Installing Apps Made Easy with HelmRelease</div><br/>
|
||||
|
||||
<div className="text">Flux CD uses a tool called HelmRelease to manage and install apps on your computer in the DOKS cluster. Think of it as a helpful guide that knows how to put apps on your computer in a simple way. This tool not only installs apps but also handles updates and fixes if something goes wrong. It's like HelmRelease is a superhero for your computer, making sure everything stays just right with your apps!</div><br/>
|
||||
|
||||
<div className="text">Every HelmRelease needs to know where to find the app it's installing. It uses different sources to do this:</div>
|
||||
<div className="text"><ol><li>HelmRepository: This is like a store for Helm charts. HelmRelease can go here to get the chart it needs.</li><li>GitRepository: Think of this as a library where HelmRelease can find charts stored in Git repositories.</li><li>S3 Bucket: This is a special storage place where HelmRelease can find charts if they're kept in S3 compatible buckets.</li></ol></div><br/>
|
||||
|
||||
|
||||
<div className="text">So, HelmRelease uses these sources to make sure it finds the right chart for your app!</div> <br/>
|
||||
<div className="text">What a HelmRelease Configuration Looks Like:</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: helm.toolkit.fluxcd.io/v2beta1
|
||||
kind: HelmRelease
|
||||
metadata:
|
||||
name: ambassador-stack
|
||||
namespace: flux-system
|
||||
spec:
|
||||
chart:
|
||||
spec:
|
||||
chart: edge-stack
|
||||
sourceRef:
|
||||
kind: HelmRepository
|
||||
name: ambassador
|
||||
version: 7.3.2
|
||||
install:
|
||||
createNamespace: true
|
||||
interval: 1m0s
|
||||
targetNamespace: ambassador
|
||||
`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Breaking Down the HelmRelease Configuration:</div>
|
||||
|
||||
<div className="text"><ol><li><kind>: This tells Flux CD it's a type of setup called HelmRelease.
|
||||
</li><br/><li><metadata.name>: It's like giving a name to this specific HelmRelease setup, such as 'ambassador-stack'.</li><br/><li><metadata.namespace>: Think of this as a special area where your HelmRelease works, like 'flux-system'.</li><br/><li><chart.spec.chart>: Specifies the name of the app's instruction manual (chart) to get from the HelmRepository, like 'ambassador'.</li><br/><li><chart.spec.sourceRef.kind>: Tells Flux CD to use a resource called HelmRepository to find the app's instruction manual (it's like a helper for HelmRelease).</li><br/><li><chart.spec.sourceRef.name>: This is the name of that HelmRepository helper.</li><br/><li><chart.spec.version>: Specifies which version of the app's instruction manual to use.</li><br/><li><spec.install.createNamespace>: Instructs Flux CD if it needs to create a special area for the app before installing it (like 'helm install --create-namespace' in commands).</li><br/><li><spec.interval>: Tells Flux CD how often it should check and make sure everything is set up correctly.</li><br/><li><spec.targetNamespace>: Specifies where the app's instruction manual should be placed, similar to saying 'helm install --namespace <name>' in commands.</li></ol></div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Customizing Apps with HelmRelease:</div>
|
||||
|
||||
<div className="text">With Flux CD's HelmRelease, you can change how apps behave by tweaking their settings. It's like adjusting the settings on your favorite game or app!</div>
|
||||
|
||||
<div className="text">You can do this in two ways:</div>
|
||||
|
||||
<div className="text"><ol><li>Using a values file: This is like giving Flux CD a file with all the changes you want to make. It's similar to saying 'helm install <name> <chart> -f values.yaml' in commands.</li><li>Setting each value individually: Instead of using a file, you can tell Flux CD each change you want to make one by one. It's like saying 'helm install <name> <chart> --set <key> <value>' in commands.</li></ol></div>
|
||||
|
||||
<div className="text">So, with HelmRelease, you have the power to customize your apps just the way you like!</div><br/>
|
||||
|
||||
<div className="text">Flux CD gives you two ways to change how your apps work:</div>
|
||||
|
||||
<div className="text"><ol><li>Inline Overrides (using <spec.values>): It's like telling Flux CD exactly what changes you want, similar to giving it a note with all the adjustments you need. This is the equivalent of saying 'helm install -f <values_file>' in commands.</li><li>Individual Overrides (using <spec.valuesFrom>): Instead of giving Flux CD a note, you can talk to it one-on-one and say each change you want. It's like saying 'helm install --set <key> <value>' in commands, but in a more detailed way.</li></ol></div>
|
||||
|
||||
<div className="text">So, with Flux CD, you have these cool options to make your apps work just the way you want!</div><br/>
|
||||
|
||||
<div className="text">How to Use <spec.values> in Flux CD:</div>
|
||||
<CodeBlock code={`...
|
||||
spec:
|
||||
values:
|
||||
loki:
|
||||
enabled: true
|
||||
config:
|
||||
schema_config:
|
||||
configs:
|
||||
- from: "2020-10-24"
|
||||
store: boltdb-shipper
|
||||
object_store: aws
|
||||
schema: v11
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Understanding <spec.values> Configuration:</div>
|
||||
|
||||
<div className="text">Think of <spec.values> as a special note where you write instructions for your app, such as what color it should use or how fast it should run.</div><br/>
|
||||
|
||||
<div className="text">But here's a caution: if you put sensitive information like passwords or API tokens directly in this note, it's not safe. Flux CD is smart, though. It provides a solution! Instead of putting secrets in the note, you can keep them in a secret vault called Kubernetes Secrets or ConfigMaps. These are like hidden safes where important things stay protected. Flux CD then knows exactly where to find these secrets when needed, keeping everything secure!</div><br/>
|
||||
|
||||
<div className="text">How to Use <spec.valuesFrom> with Kubernetes Secret: This is a way of telling Flux CD to use a secret vault called Kubernetes Secret, and it expects you to set up a secret named 'do-credentials' before using it.</div>
|
||||
|
||||
<CodeBlock code={`spec:
|
||||
valuesFrom:
|
||||
- kind: Secret
|
||||
name: do-credentials
|
||||
valuesKey: spaces_access_key
|
||||
targetPath: aws.access_key_id
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Understanding the Configuration Details:"</div>
|
||||
<div className="text"><ol><li><spec.valuesFrom.kind>: This tells Flux CD the type of secret vault or storage place to look into, like a hidden safe or a special storage box (in this case, it's a Kubernetes Secret, but it could also be a ConfigMap).</li><li><spec.valuesFrom.name>: It's like providing the name of the secret vault or storage box Flux CD should check for important information. This vault or box should be in the same special area as the HelmRelease.</li><li><spec.valuesFrom.valuesKey>: Think of this as a specific note inside the vault or box where Flux CD can find something important. If not set, Flux CD assumes it's a general set of instructions named 'values.yaml'.</li><li><spec.valuesFrom.targetPath>: This is like instructing Flux CD where to put the important information it finds. If not set, Flux CD puts the information in the main place.</li></ol></div>
|
||||
|
||||
<div className="text">In simpler terms, it's like telling Flux CD where to look (kind and name), what specific information to find (valuesKey), and where to put it (targetPath).</div><br/>
|
||||
|
||||
<div className="text">When using Flux CD to manage your apps in Kubernetes (think of it like a helpful guide for your computer), there are two types of information your apps might need:</div>
|
||||
|
||||
<div className="text"><ol><li>Basic Info: Like the everyday details your app uses, such as settings. You can keep these in a place called spec.values.</li><li>Secret Info: Some things are secret, like passwords. You don't want these out in the open. Instead, you can point to a secret stash using spec.valuesFrom.</li></ol></div>
|
||||
|
||||
<div className="text">When Flux CD sets up your app, it brings together both the basic and secret info. It's like making sure your app has everything it needs.</div><br/>
|
||||
|
||||
|
||||
<div className="text">But, because you shouldn't just put secret things out where anyone can see (like leaving your diary on a park bench), in a GitOps way of working (managing your code with Git), you use something called Sealed Secrets. It's like putting your secrets in a super-secure envelope so that only your app can open it when needed.</div>
|
||||
|
||||
|
||||
<div className="head">Keeping Secrets Safe with Sealed Secrets: A Beginner's Guide</div>
|
||||
<div className="text">Here's how it works:</div>
|
||||
|
||||
<div className="text"><ol><li>Locking Secrets: Sealed Secrets locks up your secrets, making them like a secret code only your computer can understand.</li><li>Safe Storage: You can put these locked-up secrets in a special storage place called Git. It's safe, even if it's a shared space, because nobody can open the locked-up secrets without the right key.</li><li>Flux CD Help: When you need these secrets for your apps, Flux CD, your computer helper, sees the locked-up secrets in Git. It creates a special key to open the lock, revealing your original secrets.</li><li>Unlocking for Apps: Another helper, the Sealed Secrets Controller, notices these unlocked secrets and turns them back into regular codes that your apps can use.</li></ol></div>
|
||||
|
||||
<div className="text">So, Sealed Secrets helps keep your secrets safe, even in shared spaces, and ensures your apps can still use them without any problems. It's like having a secret code and a key to unlock it whenever you need it.</div>
|
||||
|
||||
<div className="text">Next, let's see how to put a Flux CD on your DOKS cluster.</div>
|
||||
|
||||
<div className="head">Getting Started with Flux CD</div>
|
||||
|
||||
<div className="text">Setting up Flux CD is like having a helpful assistant for your computer that makes managing your apps easier. You use a tool provided by Flux CD to run a command called "flux bootstrap." This command tells your computer to set up a Flux CD on your Kubernetes cluster, enhancing its ability to handle your apps smoothly. Flux CD keeps track of your app details in a special place called Git, similar to a digital to-do list. </div><br/>
|
||||
|
||||
<div className="text">So, when you run the command, you're not only setting up a Flux CD but also saying, "Look at this list in Git to understand my apps." The good part is, if you need to run the command again, it's safe. It won't cause any issues, making it easy to remind your computer to get ready as many times as you need.</div> <br/>
|
||||
|
||||
<div className="text">When setting up Flux CD on your existing DOKS cluster, it's like getting your computer ready for a helpful assistant. Here's how you do it:</div>
|
||||
|
||||
<div className="text"><ol><li>Create a Special Key: Make a special key for your computer called a Personal Access Token (PAT). This key allows your computer to do specific tasks, like making a list of your apps.</li><li>Share the Key with Your Computer: Once you have this special key, you share it with your computer. It's like saying, "Hey, computer, here's a key that lets you make lists. Use it!" Just replace some placeholders with the actual key.</li></ol></div>
|
||||
|
||||
<div className="text">In simpler terms, you're giving your computer permission to make a list of your apps, and you're just making sure it has the right key to do it.</div>
|
||||
|
||||
<CodeBlock code={`export GITHUB_TOKEN=<YOUR_PERSONAL_ACCESS_TOKEN_HERE>`} /><br/>
|
||||
|
||||
<div className="text"> 3. Set up a folder in your own GitHub account by running a special command (don't forget to fill in your own info instead of the placeholders).</div>
|
||||
|
||||
<CodeBlock code={`flux bootstrap github \
|
||||
--owner=<YOUR_GITHUB_USER> \
|
||||
--repository=<YOUR_GITHUB_REPOSITORY_NAME> \
|
||||
--path=clusters/dev \
|
||||
--personal
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Let's break down what these instructions mean:</div>
|
||||
|
||||
<div className="text"><ol><li>--owner: This is like telling your computer who you are on GitHub, just saying, "It's me!</li><li>--repository: Think of this as asking your computer to make a special folder for Flux CD on GitHub. If the folder isn't there, your computer will create it.</li><li>--path: Imagine this as picking a specific spot inside that folder to keep all the important stuff. Flux CD will keep an eye on any changes happening in this particular spot.</li></ol></div> <br/>
|
||||
|
||||
|
||||
<div className="text">When you use the "flux bootstrap" command, it sets up everything Flux CD needs to work smoothly. It'll make a special place for Flux CD on GitHub if it's not already there, and it'll start getting Flux CD ready to go. After it's done, you'll find a bunch of files in your GitHub folder. These files, written in a language called YAML, make sure Flux CD has everything it needs to do its job with your apps. So, think of it as saying, "Hey computer, get everything ready for Flux CD to work well!</div>
|
||||
|
||||
<div className="text">Next, you can do some quick checks by:</div>
|
||||
|
||||
<CodeBlock code={`flux check`} /><br/>
|
||||
|
||||
<div className="text">The result will appear something like this:</div>
|
||||
|
||||
<CodeBlock code={`Output► checking prerequisites
|
||||
✔ Kubernetes 1.21.9 >=1.20.6-0
|
||||
► checking controllers
|
||||
✔ helm-controller: deployment ready
|
||||
► ghcr.io/fluxcd/helm-controller:v0.17.2
|
||||
✔ kustomize-controller: deployment ready
|
||||
► ghcr.io/fluxcd/kustomize-controller:v0.21.1
|
||||
✔ notification-controller: deployment ready
|
||||
► ghcr.io/fluxcd/notification-controller:v0.22.3
|
||||
✔ source-controller: deployment ready
|
||||
► ghcr.io/fluxcd/source-controller:v0.21.2
|
||||
✔ all checks passed
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After that, take a look at all Flux CD resources by:</div>
|
||||
|
||||
<CodeBlock code={`flux get all`} /><br/>
|
||||
|
||||
<div className="text">You'll see something like this (just a note: you might notice parts like "gitrepository/flux-system" and "kustomization/flux-system" doing their thing, which means they're fetching the latest updates from your main branch).</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME READY MESSAGE REVISION SUSPENDED
|
||||
gitrepository/flux-system True Fetched revision: main/6e9b41b main/6e9b41b False
|
||||
|
||||
NAME READY MESSAGE REVISION SUSPENDED
|
||||
kustomization/flux-system True Applied revision: main/6e9b41b main/6e9b41b False
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you ever need to figure out what Flux CD is up to or fix something, you can check out its logs by:</div>
|
||||
|
||||
<CodeBlock code={`flux logs`} /><br/>
|
||||
|
||||
<div className="text">You'll see something like this:</div>
|
||||
|
||||
<CodeBlock code={`Output...
|
||||
2022-03-17T10:47:21.976Z info Kustomization/flux-system.flux-system - server-side apply completed
|
||||
2022-03-17T10:47:22.662Z info Kustomization/flux-system.flux-system - server-side apply completed
|
||||
2022-03-17T10:47:22.702Z info Kustomization/flux-system.flux-system - Reconciliation finished in 9.631064885s, next run in 10m0s
|
||||
2022-03-17T10:47:19.167Z info GitRepository/flux-system.flux-system - Discarding event, no alerts found for the involved object
|
||||
2022-03-17T10:47:22.691Z info Kustomization/flux-system.flux-system - Discarding event, no alerts found for the involved object
|
||||
2022-03-17T10:47:22.709Z info Kustomization/flux-system.flux-system - Discarding event, no alerts found for the involved object
|
||||
2022-03-17T10:47:19.168Z info GitRepository/flux-system.flux-system - Reconciliation finished in 7.79283477s, next run in 1m0s
|
||||
2022-03-17T10:48:20.594Z info GitRepository/flux-system.flux-system - Reconciliation finished in 1.424279853s, next run in 1m0s
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Lastly, make sure Flux CD knows about your Git repository by:</div>
|
||||
|
||||
<CodeBlock code={`kubectl get gitrepositories.source.toolkit.fluxcd.io -n flux-system`} /><br/>
|
||||
|
||||
<div className="text">The result will be something like this (check the URL column value - it should lead to your Git repository and make sure the READY state is set to True):</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME URL READY STATUS AGE
|
||||
flux-system ssh://git@github.com/test-starterkit/starterkit_fra1.git True Fetched revision: main/6e9b41b... 9m59s
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">You'll also find several Flux CD system files in your Git repository:</div>
|
||||
|
||||
|
||||
<!-- <need to add image here > -->
|
||||
|
||||
|
||||
<div className="text">In the next step, we'll set up your Git repository in a way that Flux CD can understand. Flux CD pays attention to changes in a specific folder that you told it about when you ran the "flux bootstrap" command, and for our tutorial, it's the "clusters/dev" folder. Inside this folder, you have the freedom to create other folders or files to keep everything neat and organized. Flux CD will carefully go through all the files and folders inside "clusters/dev" to find what it needs.</div> <br/>
|
||||
|
||||
|
||||
<div className="text">You could just put everything directly into the "clusters/dev" folder, but it's a good habit to keep things well-organized and follow a set of rules for naming. This helps you stay organized and reduces confusion down the road.</div>
|
||||
|
||||
<div className="head">Setting up Your Git Repository for Flux CD - Step by Step</div>
|
||||
|
||||
<div className="text">In this step, you'll find out how to arrange your Git repository, which Flux CD uses to keep your DOKS cluster in sync. To keep things simple, we're using what's called a "mono repo" structure, where all your important stuff is in one place - think of it like a big box. Specifically, we use a folder named "clusters/dev" to store everything related to your apps. If you want to explore other ways to organize your Git repository, you can check out the official Flux CD documentation for some tips. But for now, we're keeping it easy with this one-folder approach.</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Make sure you do these steps in order:</div>
|
||||
|
||||
<div className="text"><ol><li>Get Your Flux CD Git Repository: Start by copying your Flux CD Git repository. It's like making a duplicate of your big box where all the important things are stored for looking after your DOKS cluster. Just fill in your details instead of the <> symbols. <CodeBlock code={`git clone https://github.com/<YOUR_GITHUB_USER>/<YOUR_GITHUB_REPOSITORY_NAME>.git`} /> <br/>Here's what those placeholders mean:<ol><li><YOUR_GITHUB_USER>: This is where you put your username on GitHub, the same one you used when you set up Flux CD.</li><li><YOUR_GITHUB_REPOSITORY_NAME>: This is the name of the special folder on GitHub where Flux CD keeps everything for your DOKS cluster. Remember, you set this up when you ran the "flux bootstrap" command.</li></ol></li></ol></div>
|
||||
|
||||
<div className="text">So, when you see these placeholders, just replace them with your own GitHub username and the name of the repository you created for your DOKS cluster. It's like filling in the blanks with your own information.</div> <br/>
|
||||
|
||||
|
||||
<div className="text">2. Next, go to the folder where you copied your Flux CD Git repository, and switch to the right branch, usually called "main".</div><br/>
|
||||
|
||||
<div className="text">3. Now, it's time to set up the folders to keep all the important files for Flux CD, like HelmRepository, HelmRelease, and SealedSecret manifests for each part of the Starter Kit. To do this, replace the FLUXCD_SYNC_PATH variable with the location where Flux CD checks for changes. In our Starter Kit, we use the "clusters/dev" folder path for this.</div>
|
||||
|
||||
<CodeBlock code={`FLUXCD_SYNC_PATH="clusters/dev"
|
||||
FLUXCD_HELM_MANIFESTS_PATH="$ {FLUXCD_SYNC_PATH}/helm"
|
||||
mkdir -p "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories"
|
||||
mkdir -p "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases"
|
||||
mkdir -p "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Finally, let's make sure we don't include any secret information in your repository. Open the folder where you copied your Flux CD Git repository, and add a file named ".gitignore." You can use any text editor you like. Then, copy and paste the following text into that file. The example below follows the naming style of our Starter Kit:</div>
|
||||
|
||||
<CodeBlock code={`Output# Ignore all YAML files containing the '-values-' string.
|
||||
*-values-*.yaml
|
||||
|
||||
# Do not ignore sealed YAML files.
|
||||
!*-sealed.yaml
|
||||
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you complete all the steps in this tutorial, your Git repository should look something like this:</div>
|
||||
|
||||
<CodeBlock code={`├── README.md
|
||||
├── clusters
|
||||
│ └── dev
|
||||
│ ├── flux-system
|
||||
│ │ ├── gotk-components.yaml
|
||||
│ │ ├── gotk-sync.yaml
|
||||
│ │ └── kustomization.yaml
|
||||
│ └── helm
|
||||
│ ├── releases
|
||||
│ │ ├── ambassador-stack-v7.3.2.yaml
|
||||
│ │ ├── loki-stack-v2.6.4.yaml
|
||||
│ │ ├── prometheus-stack-v35.5.1.yaml
|
||||
│ │ ├── sealed-secrets-v2.4.0.yaml
|
||||
│ │ └── velero-v2.29.7.yaml
|
||||
│ ├── repositories
|
||||
│ │ ├── ambassador.yaml
|
||||
│ │ ├── grafana.yaml
|
||||
│ │ ├── prometheus-community.yaml
|
||||
│ │ ├── sealed-secrets.yaml
|
||||
│ │ └── vmware-tanzu.yaml
|
||||
│ └── secrets
|
||||
│ ├── do-api-credentials-sealed.yaml
|
||||
│ ├── do-spaces-credentials-sealed.yaml
|
||||
│ └── prometheus-stack-credentials-sealed.yaml
|
||||
└── pub-sealed-secrets-dev-cluster.pem
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Next, we'll set up the necessary files for Flux CD for each part of the Starter Kit. Then, we'll carefully check each file and save them to your Git repository. This repository is where Flux CD looks to keep your DOKS cluster up to date. If there's any private information, like passwords, we'll keep them safe by putting them in a special encrypted file called a Kubernetes Secret. This file will also be stored in your Git repository.</div> <br/>
|
||||
|
||||
<div className="text">First, we'll use a tool called the Flux CLI to create some files. This will help you get used to working with them. After that, we'll use some files that are already made and provided by the Starter Kit. This will make things faster and easier.</div> <br/>
|
||||
|
||||
<div className="text">We're going to start with something called the Sealed Secrets Helm release. It's important because the other parts of the Starter Kit need it to work.</div>
|
||||
|
||||
<div className="head">Starting the Sealed Secrets Setup</div>
|
||||
|
||||
<div className="text">In this step, you'll use a tool called Flux CLI to create some files. These files are needed to set up something called Sealed Secrets Helm release. After that, Flux will handle installing the Sealed Secrets Controller on your DOKS cluster.</div><br/>
|
||||
|
||||
<div className="text">Follow these steps to make the necessary files for the Sealed Secrets Helm release:</div>
|
||||
<div className="text"><ol><li>Go to the folder where you cloned your Flux CD Git repository.
|
||||
Make sure the folder structure needed for this tutorial is set up and that you've set the FLUXCD_HELM_MANIFESTS_PATH environment variable.</li><br/><li>Create a file called Sealed Secrets HelmRepository manifest for Flux</li></ol></div>
|
||||
|
||||
|
||||
<CodeBlock code={`flux create source helm sealed-secrets \
|
||||
--url="https://bitnami-labs.github.io/sealed-secrets" \
|
||||
--interval="10m" \
|
||||
--export > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/sealed-secrets.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Understanding Command Options</div>
|
||||
|
||||
<!-- <div className="text"><ol><li>--url: This is the web address where the Helm repository is.</li><li>--interval: It's how often Flux checks for updates from the repository (default is every minute).</li><li>--export: This makes Flux show the information in a format called YAML on the screen
|
||||
</li></ol></div> -->
|
||||
|
||||
|
||||
<div className="text">The output looks like this (you might see it organized in a similar way to what we talked about in Using HelmRepository CRD to Specify Helm Repositories):</div>
|
||||
|
||||
<CodeBlock code={`apiVersion: source.toolkit.fluxcd.io/v1beta1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: sealed-secrets
|
||||
namespace: flux-system
|
||||
spec:
|
||||
interval: 10m0s
|
||||
url: https://bitnami-labs.github.io/sealed-secrets
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Next, get the Starter Kit's values file for Sealed Secrets. Before you use it, take a look at the file to see if there are any placeholders, like <> symbols, that you need to fill in with the right information.</div>
|
||||
|
||||
<CodeBlock code={`SEALED_SECRETS_CHART_VERSION="2.4.0"
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/06-kubernetes-secrets/assets/manifests/sealed-secrets-values-v$ {SEALED_SECRETS_CHART_VERSION}.yaml" > "sealed-secrets-values-v$ {SEALED_SECRETS_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, make the Sealed Secrets HelmRelease file for Flux CD. By default, the Kubeseal CLI expects to find the controller in a specific place and named in a certain way. So, we'll change the release name using some special instructions. This isn't necessary, but it's often done because the default location might only be available to certain advanced users, like administrators.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`SEALED_SECRETS_CHART_VERSION="2.4.0"
|
||||
flux create helmrelease "sealed-secrets-controller" \
|
||||
--release-name="sealed-secrets-controller" \
|
||||
--source="HelmRepository/sealed-secrets" \
|
||||
--chart="sealed-secrets" \
|
||||
--chart-version "$ SEALED_SECRETS_CHART_VERSION" \
|
||||
--values="sealed-secrets-values-v$ {SEALED_SECRETS_CHART_VERSION}.yaml" \
|
||||
--target-namespace="flux-system" \
|
||||
--crds=CreateReplace \
|
||||
--export > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/sealed-secrets-v$ {SEALED_SECRETS_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Explaining How to Create HelmRelease Manifest with Simple Commands</div>
|
||||
|
||||
<div className="text"><ol><li>--release-name: This is the name you want to give to your Helm release. If you don't specify one, it will use a default name based on the target namespace and HelmRelease name.</li><li>--source: This tells Flux where to find the chart. It should be in the format kind/name.namespace. The kind can be HelmRepository, GitRepository, or Bucket.</li><li>--chart: This is the name of the Helm chart you want to use.</li><li>--chart-version: Specify the version of the Helm chart you want to use.</li><li>--values: This is the path to a file containing values for configuring the Helm chart.</li><li>--target-namespace: This is the namespace where you want to install this Helm release.</li><li>--crds: This option determines what to do with Custom Resource Definitions
|
||||
(CRDs). You can choose to skip, create, or create/replace them.</li><li>--export: This option makes the command output the information in YAML format on the screen</li></ol></div>
|
||||
|
||||
|
||||
<div className="text">The result appears like this (you can see it follows a similar pattern as explained in Using HelmRelease CRD to Install Helm Charts):</div>
|
||||
|
||||
<CodeBlock code={`---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta1
|
||||
kind: HelmRelease
|
||||
metadata:
|
||||
name: sealed-secrets-controller
|
||||
namespace: flux-system
|
||||
spec:
|
||||
chart:
|
||||
spec:
|
||||
chart: sealed-secrets
|
||||
sourceRef:
|
||||
kind: HelmRepository
|
||||
name: sealed-secrets
|
||||
version: 2.4.0
|
||||
interval: 1m0s
|
||||
releaseName: sealed-secrets-controller
|
||||
targetNamespace: flux-system
|
||||
install:
|
||||
crds: Create
|
||||
upgrade:
|
||||
crds: CreateReplace
|
||||
values:
|
||||
ingress:
|
||||
enabled: false
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Lastly, upload the Git changes to the remote branch:</div>
|
||||
|
||||
<CodeBlock code={`SEALED_SECRETS_CHART_VERSION="2.4.0"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/sealed-secrets.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/sealed-secrets-v$ {SEALED_SECRETS_CHART_VERSION}.yaml"
|
||||
git commit -am "Adding Sealed Secrets manifests for Flux CD"
|
||||
git push origin
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After finishing the steps above, Flux CD will begin updating your DOKS cluster (usually within a minute, or as per the default interval). If you don't want to wait, you can manually trigger the update by:</div>
|
||||
|
||||
<CodeBlock code={`flux reconcile source git flux-system`} /><br/>
|
||||
|
||||
<div className="text">After a short while, take a look at the Flux CD Sealed Secrets Helm release:</div>
|
||||
|
||||
<CodeBlock code={`flux get helmrelease sealed-secrets-controller`} /><br/>
|
||||
|
||||
<div className="text">The result resembles:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`NAME READY MESSAGE REVISION SUSPENDED
|
||||
sealed-secrets-controller True Release reconciliation succeeded 2.4.0 False
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Check the "READY" column, it should show "True". The "MESSAGE" column tells you about the status of the update, and you'll also see a number in the "REVISION" column, which is the version of the Helm chart. Sometimes updates, especially for complex things like the Prometheus stack, can take a while, so don't worry if it's not instant—just be patient.</div>
|
||||
|
||||
<div className="text"><ol><li>The MESSAGE column will show "Reconciliation in progress" while the HelmController is installing the specified Helm chart. If there's an issue, you'll see a different message explaining what went wrong, so it's important to keep an eye on the Helm release status.</li><li>You can use the --watch flag like this: flux get helmrelease <name> --wait, to wait until the installation finishes. Just know that when using this flag, your terminal will be busy until the default timeout of 5 minutes passes (you can change this with the --timeout flag).</li><li>If something doesn't go as planned, you can search through the Flux logs and focus only on HelmRelease messages:</li></ol></div>
|
||||
|
||||
<CodeBlock code={`flux logs --kind=HelmRelease`} /><br/>
|
||||
|
||||
<div className="text">If you can't find enough information in the Flux logs, you can use the describe command on the HelmRelease using kubectl like this:</div>
|
||||
|
||||
<CodeBlock code={`kubectl describe helmrelease sealed-secrets-controller -n flux-system`} /><br/>
|
||||
|
||||
<div className="head">Exporting the Sealed Secrets Controller Public Key</div>
|
||||
<div className="text">To encrypt secrets, you'll need the public key created by the Sealed Secrets Controller when Flux CD deployed it in your DOKS cluster.</div>
|
||||
|
||||
<div className="text">Here's what to do:</div>
|
||||
|
||||
<div className="text"><ol><li>Go to the folder where you cloned your Flux CD Git repository.Follow these steps (replace any <> placeholders as needed): <br/> <CodeBlock code={`kubeseal --controller-namespace=flux-system --fetch-cert > pub-sealed-secrets-<YOUR_DOKS_CLUSTER_NAME_HERE>.pem`} /><br/> If you're having trouble with the kubeseal certificate fetch command, or if you get an empty or invalid certificate file, you can try these steps to fix it:</li><li>Open a new terminal window. Use this command to make the Sealed Secrets Controller service accessible on your computer (you can press CTRL - C to stop it after you've fetched the public key): <br/> <CodeBlock code={`kubectl port-forward service/sealed-secrets-controller 8080:8080 -n flux-system`} /><br/></li></ol></div>
|
||||
|
||||
<div className="text">After that, return to your original terminal and use the command to get the public key (make sure to replace any <> placeholders as needed):</div>
|
||||
|
||||
<CodeBlock code={`curl --retry 5 --retry-connrefused localhost:8080/v1/cert.pem > pub-sealed-secrets-<YOUR_DOKS_CLUSTER_NAME_HERE>.pem`} /><br/>
|
||||
|
||||
<div className="text">Lastly, upload the public key file to your remote Git repository. It's safe to do this because the public key alone can't be used to decrypt anything; the private key, which is needed for decryption, is securely stored in your DOKS cluster. Run the following commands and replace any placeholders like <> with the correct information:</div>
|
||||
|
||||
<CodeBlock code={`git add pub-sealed-secrets-<YOUR_DOKS_CLUSTER_NAME_HERE>.pem
|
||||
git commit -m "Adding Sealed Secrets public key for cluster <YOUR_DOKS_CLUSTER_NAME_HERE>"
|
||||
git push origin
|
||||
`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: In this tutorial, we're using a special place called the flux-system namespace to keep some secrets in Kubernetes. Just make sure that regular users or applications can't get into this place by setting up RBAC (Role-Based Access Control).</div>
|
||||
|
||||
|
||||
<div className="head">Setting Up Cert-Manager for Wildcard Certificates</div>
|
||||
<div className="text">If you want to use wildcard certificates in your cluster or need proper TLS termination for the Nginx Ingress Controller, you'll need to install Cert-Manager.</div>
|
||||
|
||||
<div className="text">Here are the steps to follow:</div>
|
||||
|
||||
<div className="text"><ol><li>Go to the folder where you saved your Flux CD Git repository. Make sure you have the right folders set up for this tutorial, and that you've set the FLUXCD_HELM_MANIFESTS_PATH environment variable (you can find instructions for this in Step 4 - Cloning the Flux CD Git Repository and Preparing the Layout).</li> <br/> <li>Next, download the Jetstack HelmRepository manifest file from the Starter Kit Git repository. <br/><CodeBlock code={`curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/repositories/jetstack.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/jetstack.yaml"`} /><br/> </li><li>Next, get the Cert-Manager HelmRelease manifest file from the Starter Kit Git repository:<br/><CodeBlock code={`CERT_MANAGER_CHART_VERSION="1.8.0"
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/cert-manager-v$ {CERT_MANAGER_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/cert-manager-v$ {CERT_MANAGER_CHART_VERSION}.yaml"
|
||||
`} /><br/></li> <li>Next, open the downloaded HelmRelease manifest file in a text editor. It's a good idea to use one with support for YAML linting, like VS Code. Make any necessary adjustments to fit your requirements. If you see placeholders like <>, be sure to replace them with the correct information.<br/><CodeBlock code={`CERT_MANAGER_CHART_VERSION="1.8.0"
|
||||
code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/cert-manager-v$ {CERT_MANAGER_CHART_VERSION}.yaml"
|
||||
`} /><br/></li><li>Lastly, upload the Git changes to the remote repository: <br/> <CodeBlock code={`CERT_MANAGER_CHART_VERSION="1.8.0"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/jetstack.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/cert-manager-v$ {CERT_MANAGER_CHART_VERSION}.yaml"
|
||||
git commit -am "Adding Cert-Manager manifests for Flux CD"
|
||||
git push origin
|
||||
`} /><br/></li></ol></div>
|
||||
|
||||
<div className="text">Once you finish the steps above, Flux CD will begin updating your DOKS cluster. It usually takes about a minute, depending on the default interval. If you're in a hurry, you can manually trigger the update by:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`flux reconcile source git flux-system`} /><br/>
|
||||
<div className="text">After a short while, please check the status of the HelmRelease:</div>
|
||||
|
||||
<CodeBlock code={`flux get helmrelease cert-manager`} /><br/>
|
||||
<div className="text">The output will look like this:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME READY MESSAGE REVISION SUSPENDED
|
||||
cert-manager True Release reconciliation succeeded v1.6.1 False
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Look at the "READY" column, it should say "True". The "MESSAGE" column tells you how the update is going, and you'll see a number in the "REVISION" column, which is the version of the Helm chart. Some updates, like for the Prometheus stack, might take longer, so don't worry if it's not finished right away—just be patient.</div>
|
||||
|
||||
<div className="text"><ol><li>The MESSAGE column shows 'Reconciliation in progress' while Flux CD is setting up the Helm chart. If there's a problem, you'll see a different message explaining it, so it's important to check the Helm release status.</li><li>You can use the --watch flag, like this: flux get helmrelease <name> --wait, to wait until everything's done. Just know that your terminal will be busy until it finishes (you can change the timeout if needed).</li><li>If something goes wrong, you can search the Flux logs for HelmRelease messages.</li></ol></div>
|
||||
|
||||
<div className="text">flux logs --kind=HelmRelease</div>
|
||||
|
||||
<div className="text">If you can't find enough information in the Flux logs, you can use a command called "describe" on the helmrelease using kubectl like this:</div>
|
||||
|
||||
<CodeBlock code={`kubectl describe helmrelease cert-manager -n flux-system`} /><br/>
|
||||
|
||||
<div className="text">Next, you'll make Flux CD files for the Ambassador (or Nginx) ingress.</div>
|
||||
|
||||
|
||||
<div className="head">Setting up the Ingress Controller with Helm</div>
|
||||
<div className="text">In this step, you'll use ready-made files to set up your chosen Ingress Controller with Flux CD. Then, Flux will start installing the Ingress Controller on your DOKS cluster.</div>
|
||||
|
||||
<div className="text">You have two choices for setting up your Ingress Controller, which is like a traffic director for your web applications:</div>
|
||||
|
||||
<div className="text"><ol><li>Ambassador Ingress Helm Release</li><li>Nginx Ingress Helm Release</li></ol></div>
|
||||
|
||||
<div className="text">These are tools to help manage how internet traffic gets directed to your apps, kind of like traffic signs for your website.</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Follow these easy steps to get started:</div>
|
||||
|
||||
<div className="text"><ol><li>Navigate to Your Flux CD Git Repository: Go to the folder where you stored your Flux CD Git repository. Make sure the required folders are set up correctly (if you're unsure, check Step 4 of the tutorial for details).</li><br/><li>Fetch the HelmRepository File: Now, grab the file that tells Flux CD how to handle Helm charts. Choose the option that matches the Ingress Controller you want (either Ambassador or Nginx). This file helps set up the necessary configurations.</li></ol></div>
|
||||
|
||||
<div className="text">That's it! You're on your way to configuring Flux CD for your project.</div>
|
||||
|
||||
<div className="text"><span className="blue">Ambassador</span> Ingress:</div>
|
||||
|
||||
<CodeBlock code={`curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/repositories/ambassador.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/ambassador.yaml"`} /><br/>
|
||||
|
||||
|
||||
<div className="text"><span className="blue">Nginx</span>Ingress:</div>
|
||||
|
||||
<CodeBlock code={`curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/repositories/kubernetes-community-nginx.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/kubernetes-community-nginx.yaml"`} /><br/>
|
||||
|
||||
|
||||
<div className="text">3. Please get the file that sets up HelmRelease from the Starter Kit Git repository. Choose the one that matches the Ingress Controller you want to install and set up</div><br/>
|
||||
|
||||
|
||||
<div className="text">Ambassador Ingress:</div>
|
||||
|
||||
<CodeBlock code={`AMBASSADOR_CHART_VERSION="7.3.2"
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/ambassador-stack-v$ {AMBASSADOR_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/ambassador-stack-v$ {AMBASSADOR_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Nginx Ingress:</div>
|
||||
|
||||
<CodeBlock code={`NGINX_CHART_VERSION="4.1.3"
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/nginx-v$ {NGINX_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/nginx-v$ {NGINX_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">4. Now, open the HelmRelease file you downloaded using an editor like VS Code. Look for specific parts you may need to change, like anything in <>. Make sure to update these parts based on your preferences. If there are placeholders, replace them with the information you want to use. Just focus on making the file suit your needs.</div>
|
||||
|
||||
<div className="text">Ambassador Ingress:</div>
|
||||
|
||||
<CodeBlock code={`AMBASSADOR_CHART_VERSION="7.3.2"
|
||||
code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/ambassador-stack-v$ {AMBASSADOR_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Nginx Ingress:</div>
|
||||
|
||||
<CodeBlock code={`NGINX_CHART_VERSION="4.1.3"
|
||||
code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/nginx-v$ {NGINX_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: Take a look at the HelmRelease file to see how it handles fixing things when there's a problem during installation or upgrade. If you want more details on how it works, you can visit the 'Configuring Failure Remediation' page for additional information about the options available in Flux CD for dealing with issues during Helm install or upgrade.</div>
|
||||
|
||||
|
||||
|
||||
<CodeBlock code={`...
|
||||
install:
|
||||
createNamespace: true
|
||||
remediation:
|
||||
retries: 3
|
||||
upgrade:
|
||||
remediation:
|
||||
retries: 3
|
||||
...
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">5. At the end, save your changes in Git by committing them to the remote branch. Choose the option that matches the Ingress Controller you want to install and set up.</div>
|
||||
|
||||
<div className="text">Ambassador Ingress:</div>
|
||||
|
||||
<CodeBlock code={`AMBASSADOR_CHART_VERSION="7.3.2"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/ambassador.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/ambassador-stack-v$ {AMBASSADOR_CHART_VERSION}.yaml"
|
||||
git commit -am "Adding Ambassador manifests for Flux CD"
|
||||
git push origin
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Nginx Ingress:</div>
|
||||
|
||||
<CodeBlock code={`NGINX_CHART_VERSION="4.1.3"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/kubernetes-community-nginx.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/nginx-v$ {NGINX_CHART_VERSION}.yaml"
|
||||
git commit -am "Adding Nginx manifests for Flux CD"
|
||||
git push origin
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After you've done the earlier steps, Flux CD will automatically check and update your DOKS cluster in about a minute (if using the default setting). If you're in a hurry and don't want to wait, you can manually trigger this process by following these steps:</div>
|
||||
|
||||
<div className="text">flux reconcile source git flux-system</div>
|
||||
<div className="text">After waiting a bit, check the status of the HelmRelease. Choose the option that matches the Ingress Controller you installed.</div>
|
||||
|
||||
<div className="text">Ambassador Ingress:</div>
|
||||
|
||||
<CodeBlock code={`flux get helmrelease ambassador-stack`} /><br/>
|
||||
|
||||
<div className="text">The result will appear something like this:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`OutputNAME READY MESSAGE REVISION SUSPENDED
|
||||
ambassador-stack True Release reconciliation succeeded 7.3.2 False
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">Nginx Ingress:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`flux get helmrelease ingress-nginx`} /><br/>
|
||||
|
||||
<div className="text">The result will appear something like this:</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME READY MESSAGE REVISION SUSPENDED
|
||||
ingress-nginx True Release reconciliation succeeded 4.1.3 False
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Check the 'READY' column, it should show 'True'. The 'MESSAGE' column will tell you about the status of the reconciliation, and you'll also see a 'REVISION' number which represents the version of the Helm chart. Keep in mind that some installations, like Prometheus stack, might take longer, so just be patient.</div>
|
||||
|
||||
<div className="text"><ol><li>While the HelmController is busy installing the Helm chart, the 'MESSAGE' column will show 'Reconciliation in progress'. If anything goes wrong, you'll see a different message explaining the issue. So, keep an eye on the Helm release status.
|
||||
</li><br/><li>If you want to wait for the installation to finish, you can use the command 'flux get helmrelease <name> --wait'. Just know that in this mode, your terminal will be busy until it finishes or reaches the default timeout of 5 minutes (you can change this with the --timeout flag).</li><br/><li>If there's a problem, you can check the Flux logs for HelmRelease messages. Here's how to do it:</li></ol></div>
|
||||
|
||||
<CodeBlock code={`flux logs --kind=HelmRelease`} /><br/>
|
||||
|
||||
<div className="text">If you can't find enough information in the Flux logs, you can use the 'describe' command with 'kubectl' on the HelmRelease. Here's how:</div>
|
||||
|
||||
|
||||
<CodeBlock code={`kubectl describe helmrelease ingress-nginx -n flux-system`} /><br/>
|
||||
|
||||
|
||||
<div className="text">To get more details about how the Ingress Controller is doing, check out the tutorial for either Ambassador Ingress or Nginx Ingress.</div>
|
||||
|
||||
<div className="text">Now, let's move on to setting up Flux CD manifests for the Prometheus stack.</div>
|
||||
|
||||
<div className="head">Setting up Prometheus Stack with Flux CD</div>
|
||||
|
||||
<div className="text">In this step, we're going to use ready-made instructions to create the Prometheus Helm release with Flux CD. Flux will then take care of installing Prometheus on your DOKS cluster. The Prometheus stack also brings Grafana along, and we'll set up the administrator credentials so you can access the dashboards. We'll show you how to use the kubeseal CLI along with the Sealed Secrets Controller to protect sensitive information stored in Kubernetes Secrets. Finally, we'll explore how the Flux CD HelmRelease manifest helps us link to Grafana credentials safely stored in Kubernetes Secrets.</div> <br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>To prepare for installing Prometheus, follow these steps:</div>
|
||||
|
||||
<div className="text"><ol><li>hange Directory: Go to the directory where you cloned your Flux CD Git repository. Make sure everything's set up correctly according to the tutorial's directory structure. If you're unsure, check Step 4 for guidance.</li><br/><li>Fetch Prometheus HelmRepository Manifest: Get the Prometheus HelmRepository manifest from the Starter Kit Git repository. This will give you the necessary files to set up Prometheus. <br/><CodeBlock code={`curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/repositories/prometheus-community.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/prometheus-community.yaml"`} /><br/></li></ol></div>
|
||||
|
||||
|
||||
<div className="text">3. First, make sure you have Sealed Secrets, a tool for keeping your secrets secure. Then, obtain a special key known as the Sealed Secrets public key as per the given instructions. Now, secure your Grafana dashboard password by using Kubernetes, a tool for managing things digitally. Create a secure space, place your password inside, and lock it with the special key. This ensures that only authorized entities can access your password, providing a layer of protection for your sensitive information.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`SEALED_SECRETS_PUB_KEY="<YOUR_SEALED_SECRETS_PUB_KEY_NAME_HERE>"
|
||||
GRAFANA_ADMIN_PASSWORD="<YOUR_GRAFANA_ADMIN_PASSWORD_HERE>"
|
||||
kubectl create secret generic "prometheus-stack-credentials" \
|
||||
--namespace flux-system \
|
||||
--from-literal=grafana_admin_password="$ {GRAFANA_ADMIN_PASSWORD}" \
|
||||
--dry-run=client -o yaml | kubeseal --cert="$ {SEALED_SECRETS_PUB_KEY}" \
|
||||
--format=yaml > "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/prometheus-stack-credentials-sealed.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">The command has a few parts explained below:</div>
|
||||
|
||||
<div className="text">--namespace: This is like telling the computer where to store the secret. It's a specific place called a namespace in Kubernetes.</div>
|
||||
|
||||
<div className="text">--from-literal: Imagine putting a secret code directly into the computer. This part helps create a secret by using a simple value, like your Grafana admin password.</div>
|
||||
|
||||
<div className="text">--dry-run=client: Think of this as practicing before doing the real thing. It's like checking if everything works without actually making any changes. This helps make sure everything is set up correctly.</div>
|
||||
|
||||
<div className="text">4. Now, go and get the file that sets up Prometheus using a tool called Helm. You can find this file in the Starter Kit Git repository.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`PROMETHEUS_CHART_VERSION="35.5.1"
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/prometheus-stack-v$ {PROMETHEUS_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/prometheus-stack-v$ {PROMETHEUS_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">5. Now, let's take a look at the file we just downloaded for setting up Prometheus using Helm. You can use a program like VS Code (or any text editor you prefer). Make sure to replace any placeholders enclosed in <> brackets with the specific information you need.</div>
|
||||
|
||||
<CodeBlock code={`PROMETHEUS_CHART_VERSION="35.5.1"
|
||||
|
||||
code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/prometheus-stack-v$ {PROMETHEUS_CHART_VERSION}.yaml"`} /><br/>
|
||||
|
||||
|
||||
<div className="note"><strong>Note</strong>: Now, let's find out how the secret named 'prometheus-stack-credentials' is used in the Prometheus setup. Look at the part of the code below to see how it's mentioned:</div>
|
||||
|
||||
|
||||
<!-- <CodeBlock code={`valuesFrom:
|
||||
- kind: Secret
|
||||
name: do-spaces-credentials # Kubernetes secret holding DO Spaces credentials
|
||||
valuesKey: access_key_id # Key from the `do-spaces-credentials` secret, holding the DO Spaces Access Key ID
|
||||
targetPath: loki.config.storage_config.aws.access_key_id # Helm value to override
|
||||
optional: false # Helm release will fail if value is not found
|
||||
- kind: Secret
|
||||
name: do-spaces-credentials
|
||||
valuesKey: secret_access_key # Key from the `do-spaces-credentials` secret, holding the DO Spaces Secret Key
|
||||
targetPath: loki.config.storage_config.aws.secret_access_key
|
||||
optional: false
|
||||
`} /><br/> -->
|
||||
|
||||
|
||||
|
||||
<div className="text">Lastly, save your changes in Git and upload them to the main online storage space, which is like sharing your work with others. This helps keep everyone on the same page.</div>
|
||||
|
||||
<CodeBlock code={`LOKI_CHART_VERSION="2.6.4"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/grafana.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-spaces-credentials-sealed.yaml"
|
||||
git commit -am "Adding Loki stack manifests for Flux CD"
|
||||
git push origin
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After waiting for a bit, let's check the configuration details of Prometheus using HelmRelease:</div>
|
||||
|
||||
<CodeBlock code={`flux get helmrelease kube-prometheus-stack`} /><br/>
|
||||
|
||||
<div className="text">The result you see resembles something like this:</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME READY MESSAGE REVISION SUSPENDED
|
||||
kube-prometheus-stack True Release reconciliation succeeded 35.5.1 False
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's find the 'READY' column in the output. If it says 'True', everything is good to go! Check the 'MESSAGE' column for updates on what's happening, and there's also a 'REVISION' number that shows the version of the setup. Sometimes, big setups like Prometheus take a bit more time, so don't worry if it's not super quick. Just hang in there and be patient.</div>
|
||||
|
||||
<div className="text"><ol><li>Keep an eye on the 'MESSAGE' column; it will show 'Reconciliation in progress' while the HelmController is setting up the Helm chart. If anything goes awry, you'll see a different message explaining the issue, so be sure to check the status.</li><li>You can use a special command like this: 'flux get helmrelease <name> --wait' and it will keep you updated until it's done. Just know that your terminal might be tied up during this time, and it might take up to 5 minutes (though you can change this if needed).</li><li>If something doesn't work out, you can look in the Flux logs. Specifically, filter for messages related to HelmRelease, and that might give you clues on what went wrong</li></ol></div>
|
||||
|
||||
<CodeBlock code={`flux logs --kind=HelmRelease`} /><br/>
|
||||
|
||||
<div className="text">If you still need more details and the Flux logs don't provide enough, you can use another command called 'describe'. This command helps you get a closer look at the HelmRelease setup using a tool called 'kubectl'. It's like getting a detailed report on what's happening with your setup. Here's how you do it:</div>
|
||||
|
||||
<CodeBlock code={`kubectl describe helmrelease kube-prometheus-stack -n flux-system`} /><br/>
|
||||
|
||||
<div className="text">Now, let's see if the special secret called 'prometheus-stack-credentials' was made too. You can check this by using another command, 'kubectl get secret prometheus-stack-credentials -n flux-system -o yaml'. This will let you peek inside the secret and see what's stored there. It's a bit like opening a locked box to see what's inside:</div>
|
||||
|
||||
<CodeBlock code={`kubectl get secret prometheus-stack-credentials -n flux-system`} /><br/>
|
||||
|
||||
<div className="text">At last, let's make sure everything's working with Prometheus! Here are some quick checks you can do:</div>
|
||||
|
||||
<div className="text"><ol><li>To see the Prometheus dashboard, run: 'kubectl port-forward svc/kube-prom-stack-kube-prome-prometheus 9090:9090 -n monitoring'. It's like opening a window to peek inside.</li><li>For Grafana dashboards, try this: 'kubectl --namespace monitoring port-forward svc/kube-prom-stack-grafana 3000:80'. It's another way to look at things.</li><li>Lastly, to check the storage where Prometheus keeps its data, run: 'kubectl get pvc -n monitoring'. This is like checking the space where all the important stuff is stored.</li></ol></div>
|
||||
|
||||
<div className="text">Make sure to take a look at the '04-setup-observability' tutorial for additional info on checking how well your Prometheus setup is doing.</div>
|
||||
|
||||
<div className="text">Now, onto the next step! We're going to create the instructions for setting up the Loki stack. And the cool part is, you'll let Flux CD do most of the work for you automatically. It's like giving your computer a set of instructions, and it takes care of the rest.</div><br/>
|
||||
|
||||
|
||||
<div className="head">Easy Loki Setup with Flux CD</div>
|
||||
|
||||
<div className="text">In this step, we'll get Loki up and running smoothly with Flux CD. Imagine giving your computer a clear guide to effortlessly install Loki on your cluster. Loki needs a secure spot to store its data, so we'll use a service like Cloudtopiaa Spaces for that. We'll also dive into keeping important info safe using Kubeseal CLI with Sealed Secrets Controller. Then, we'll explore how Flux CD cleverly uses a HelmRelease manifest to securely access the Cloudtopiaa Spaces credentials stored in Kubernetes Secrets. It's all about making sure Loki is set up securely and works like a charm!</div>
|
||||
|
||||
<div className="text">Let's go step by step:</div>
|
||||
|
||||
<div className="text"><ol><li>Start by going to the folder where you cloned your Flux CD Git repository. Check if you've set up the folders the way we explained.</li><br/><li>Now, grab the Loki magic instructions we have stored. It's like getting a special recipe from a cookbook – we're fetching it from the Starter Kit Git place.<br/> <CodeBlock code={`curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/repositories/grafana.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/grafana.yaml"
|
||||
`} /><br/></li><li>First, make sure you've shared a special key with your computer, as we explained in the part about exporting the Sealed Secrets Controller Public Key. If you haven't done that yet, make sure to replace any empty spots with the right information:</li></ol></div>
|
||||
|
||||
|
||||
<CodeBlock code={`SEALED_SECRETS_PUB_KEY="<YOUR_SEALED_SECRETS_PUB_KEY_NAME_HERE>"
|
||||
DO_SPACES_ACCESS_KEY="<YOUR_DO_SPACES_ACCESS_KEY_HERE>"
|
||||
DO_SPACES_SECRET_KEY="<YOUR_DO_SPACES_SECRET_KEY_HERE>"
|
||||
kubectl create secret generic "do-spaces-credentials" \
|
||||
--namespace flux-system \
|
||||
--from-literal=access_key_id="$ {DO_SPACES_ACCESS_KEY}" \
|
||||
--from-literal=secret_access_key="$ {DO_SPACES_SECRET_KEY}" \
|
||||
--dry-run=client -o yaml | kubeseal --cert="$ {SEALED_SECRETS_PUB_KEY}" \
|
||||
--format=yaml > "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-spaces-credentials-sealed.yaml"`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>The command we used consists of a few parts:</div>
|
||||
|
||||
<div className="text">--namespace: This sets the place where the secret, containing Kubernetes access credentials, will be kept, like picking a specific folder.</div><br/>
|
||||
|
||||
<div className="text">--from-literal: This is about creating the secret by putting in the actual access key ID and secret access key, like noting down important information.</div> <br/>
|
||||
|
||||
<div className="text">--dry-run=client: It's like practicing the command. It shows what the secret, with Kubernetes access credentials, would look like without actually saving it permanently. Think of it as double-checking your work before making it final.</div> <br/>
|
||||
|
||||
|
||||
<div className="text">4. Now, get the instructions for setting up Loki with Flux CD from the Starter Kit Git repository. It's like grabbing a step-by-step guide to make Loki work on your computer using Flux CD.</div>
|
||||
|
||||
<CodeBlock code={`LOKI_CHART_VERSION="2.6.4"
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, take a look at the Loki setup instructions you just downloaded. You can open them in a text editor, like VS Code, which is like using a special notebook for computer instructions. Check for any blank spots marked with <> and fill them in with your specific information. It's a bit like personalizing a recipe to make it just the way you like!</div>
|
||||
|
||||
<CodeBlock code={`LOKI_CHART_VERSION="2.6.4"
|
||||
code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: Take a look at how the 'do-spaces-credentials' secret is used in the Loki setup instructions. It's like finding a specific item in a set of directions – this secret is essential for Loki to function correctly. Check the provided instructions to see how it's a key part of the whole process!</div>
|
||||
|
||||
<!-- <CodeBlock code={`valuesFrom:
|
||||
- kind: Secret
|
||||
name: do-spaces-credentials # Kubernetes secret holding DO Spaces credentials
|
||||
valuesKey: access_key_id # Key from the `do-spaces-credentials` secret, holding the DO Spaces Access Key ID
|
||||
targetPath: loki.config.storage_config.aws.access_key_id # Helm value to override
|
||||
optional: false # Helm release will fail if value is not found
|
||||
- kind: Secret
|
||||
name: do-spaces-credentials
|
||||
valuesKey: secret_access_key # Key from the `do-spaces-credentials` secret, holding the DO Spaces Secret Key
|
||||
targetPath: loki.config.storage_config.aws.secret_access_key
|
||||
optional: false
|
||||
`} /><br/> -->
|
||||
|
||||
|
||||
<div className="text">At last, save your changes in Git and share them with others. Think of it like saving your work and letting everyone else know about the updates you made.</div>
|
||||
|
||||
<CodeBlock code={`LOKI_CHART_VERSION="2.6.4"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/grafana.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-spaces-credentials-sealed.yaml"
|
||||
git commit -am "Adding Loki stack manifests for Flux CD"
|
||||
git push origin
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After waiting for a bit, let's check the Loki setup instructions again. It's like looking back at the steps to make sure everything is going as planned.</div>
|
||||
|
||||
<CodeBlock code={`flux get helmrelease loki-stack`} /><br/>
|
||||
|
||||
<div className="text">The result you see is something like this:</div>
|
||||
<CodeBlock code={`OutputNAME READY MESSAGE REVISION SUSPENDED
|
||||
loki-stack True Release reconciliation succeeded 2.6.4 False
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Check the 'READY' column – it should say 'True.' The 'MESSAGE' column will show how things are going, and there's also a number called 'REVISION' that represents the version of the setup. Sometimes, setups like Prometheus might take a bit longer, so just hang in there and be patient.</div>
|
||||
|
||||
<div className="text"><ol><li>As the HelmController installs the setup, the 'MESSAGE' column will say 'Reconciliation in progress.' If something doesn't go as planned, you'll see a different message explaining what happened. Make sure to keep an eye on how things are going.</li><br/><li>To wait until everything finishes, you can use a special command with '--watch' like this: 'flux get helmrelease <name> --wait.' It's like keeping an eye on the cooking timer.</li><br/><li>Just remember, your computer might pause for up to 5 minutes in this mode, but you can change this time if needed. If things go wrong, you can check the Flux logs to find messages related to the setup using a filter.</li></ol></div>
|
||||
|
||||
<CodeBlock code={`flux logs --kind=HelmRelease`} /> <br/>
|
||||
|
||||
|
||||
<div className="text">If you don't find enough details in the Flux logs, you can use another command. It's like asking your computer to explain things more. Just run 'kubectl describe helmrelease <name>' – it's a bit like asking for a detailed report on what's happening with your setup</div>
|
||||
|
||||
<CodeBlock code={`kubectl describe helmrelease loki-stack -n flux-system`} /><br/>
|
||||
|
||||
<div className="text">At the end, make sure the 'do-spaces-credentials' secret is created. You can check it by running 'kubectl get secret do-spaces-credentials -n flux-system -o yaml'. Think of it like double-checking to see if your computer has safely stored the secret information you provided.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get secret do-spaces-credentials -n flux-system`} /><br/>
|
||||
|
||||
<div className="text">For more details on how to check if Loki Stack is working well, refer to the tutorial. <br/> <br/> Now, let's move on to the next step! We're going to create the instructions for Velero, and Flux CD will take care of setting it up automatically. It's like giving your computer a list of steps, and it does the work for you!</div>
|
||||
|
||||
|
||||
<div className="head">Simple Velero Setup with Flux CD</div>
|
||||
|
||||
<div className="text">Now, let's make Velero work smoothly with Flux CD. Think of it as telling your computer an easy recipe to automatically install Velero on your DOKS cluster.</div> <br/>
|
||||
|
||||
<div className="text">Velero needs a safe place to keep backups, so we'll use a DO Spaces bucket. To make this happen, you'll need special credentials, but don't worry! We'll guide you on keeping them secure using kubeseal CLI with Sealed Secrets Controller. Then, we'll show Flux CD how to use these secure credentials to install Velero using the HelmRelease manifest. It's all about making Velero setup secure and easy!</div><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: Before moving forward, just make sure that you've already set up the 'do-spaces-credentials' sealed secret on your DOKS cluster. You can find details on how to do this in the section where we created the Helm Release for Loki Stack</div> <br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Getting Ready for Velero Setup</div>
|
||||
|
||||
<div className="text"><ol><li>Start by heading to the folder where you saved your Flux CD Git repository. Make sure everything is set up correctly by checking the directories and making sure the FLUXCD_HELM_MANIFESTS_PATH environment variable is set. If you're unsure, refer back to the section where we explained how to clone the Flux CD Git Repository and set up the layout.</li><br/><li>Next, grab the Velero HelmRepository instructions from the Starter Kit Git repository. It's like picking up a helpful guide to get Velero ready on your computer using Flux CD. <br/><CodeBlock code={`curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/repositories/vmware-tanzu.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/vmware-tanzu.yaml"`} /><br/> </li><li>Create and encrypt a special space for Velero HelmRelease to use a secret code. Make sure you have the Sealed Secrets key exported, as explained in "Exporting the Sealed Secrets Controller Public Key" (replace <> placeholders accordingly).<br/><CodeBlock code={`SEALED_SECRETS_PUB_KEY="<YOUR_SEALED_SECRETS_PUB_KEY_NAME_HERE>"
|
||||
DO_API_TOKEN="<YOUR_DO_API_TOKEN_HERE>"
|
||||
kubectl create secret generic "do-api-credentials" \
|
||||
--namespace flux-system \
|
||||
--from-literal=do_api_token="$ {DO_API_TOKEN}" \
|
||||
--dry-run=client -o yaml | kubeseal --cert="$ {SEALED_SECRETS_PUB_KEY}" \
|
||||
--format=yaml > "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-api-credentials-sealed.yaml"
|
||||
`} /><br/></li></ol></div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Understanding the Command:</div>
|
||||
|
||||
<div className="text"><ul><li>--namespace: Picture this as telling the computer in which specific area (like a room) of the Kubernetes system it should keep the secret.</li><li>--from-literal: Imagine you're instructing the computer, "Hey, create a secret and put this special code (your DO API token) inside it." This special code is used by Velero within the Kubernetes environment.</li><li>--dry-run=client: It's akin to practicing before you actually do it. This part helps you see what the secret looks like without actually storing it in the computer's memory within the Kubernetes system. It's like making a draft first.</li></ul></div>
|
||||
|
||||
|
||||
<div className="text">Now, get the instructions for setting up the Loki stack from the Starter Kit Git repository.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`VELERO_CHART_VERSION="2.29.7"
|
||||
curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/velero-v$ {VELERO_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/velero-v$ {VELERO_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">5. Next, take a look at the downloaded Velero HelmRelease instructions using a tool like VS Code. Make any changes you need. If you see <>, make sure to replace them with the right information.</div>
|
||||
|
||||
<CodeBlock code={`VELERO_CHART_VERSION="2.29.7"
|
||||
code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/velero-v$ {VELERO_CHART_VERSION}.yaml"
|
||||
`} /><br/>
|
||||
|
||||
<div className="text"><ul><li>You can understand how the secrets named do-api-credentials and do-spaces-credentials are used in the Velero HelmRelease instructions by checking the following part:</li></ul></div>
|
||||
|
||||
|
||||
<!-- <CodeBlock code={`valuesFrom:
|
||||
- kind: Secret
|
||||
name: do-api-credentials # Kubernetes secret holding DO API token
|
||||
valuesKey: do_api_token # Key from the `do-api-credentials` secret, holding the DO API token
|
||||
targetPath: configuration.extraEnvVars.DIGITALOCEAN_TOKEN # Helm value to override
|
||||
optional: false # Helm release will fail if value is not found
|
||||
- kind: Secret
|
||||
name: do-spaces-credentials # Kubernetes secret holding DO Spaces credentials
|
||||
valuesKey: access_key_id # Key from the `do-spaces-credentials` secret, holding the DO Spaces Access Key ID
|
||||
targetPath: configuration.extraEnvVars.AWS_ACCESS_KEY_ID
|
||||
optional: false
|
||||
- kind: Secret
|
||||
name: do-spaces-credentials
|
||||
valuesKey: secret_access_key # Key from the `do-spaces-credentials` secret, holding the DO Spaces Secret Key
|
||||
targetPath: configuration.extraEnvVars.AWS_SECRET_ACCESS_KEY
|
||||
optional: false
|
||||
`} /><br/> -->
|
||||
|
||||
|
||||
<div className="text"><ul><li>Remember, the secret information we talked about earlier is placed in a special area called environment variables (look for configuration.extraEnvVars in the instructions). Keep in mind that if you check the Velero deployment details, these values might be visible in plain text. On real-world systems, you can add extra security measures (like RBAC) to limit who can see this information, especially in important places like production environments.</li></ul></div>
|
||||
|
||||
<CodeBlock code={`kubectl describe deployment velero -n velero | grep AWS_ACCESS_KEY_ID`} /><br/>
|
||||
|
||||
|
||||
<div className="text"><ul><li>Lastly, save your changes in Git by committing them to the remote branch.</li></ul></div>
|
||||
|
||||
<CodeBlock code={`VELERO_CHART_VERSION="2.29.7"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/vmware-tanzu.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/velero-v$ {VELERO_CHART_VERSION}.yaml"
|
||||
git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-api-credentials-sealed.yaml"
|
||||
git commit -am "Adding Velero manifests for Flux CD"
|
||||
git push origin
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">After a little while, please take a look at the Velero HelmRelease again.</div>
|
||||
<CodeBlock code={`flux get helmrelease velero-stack`} /><br/>
|
||||
|
||||
<div className="text">The result you'll see should look something like this:</div>
|
||||
|
||||
<CodeBlock code={`OutputNAME READY MESSAGE REVISION SUSPENDED
|
||||
velero-stack True Release reconciliation succeeded 2.29.7 False
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Check the column labeled READY - it should show "True." You can also see the status of the process in the column called MESSAGE, along with a number called REVISION, which tells you the version of the Helm chart. Keep in mind that some setups may take more time to finish, like the Prometheus stack. So, just hang in there and be patient.</div> <br/>
|
||||
|
||||
|
||||
<div className="text"><ol><li>When the system is working to install the Helm chart, you'll see a message saying "Reconciliation in progress" in the MESSAGE column. If there's a problem, a different message will explain what went wrong. So, keep an eye on the status of your Helm release.</li><br/> <li>You can use a command like flux get helmrelease <name> --wait --watch to patiently wait until everything is done. Just note that your terminal will be occupied until it's finished or a default timeout of 5 minutes passes (you can change this with the --timeout option).</li><br/> <li>If things don't go well, you can check the Flux logs. Specifically, you can filter them to only show messages related to HelmRelease.</li></ol></div>
|
||||
|
||||
<CodeBlock code={`flux logs --kind=HelmRelease`} /><br/>
|
||||
|
||||
<div className="text">If you don't find enough info in the Flux logs, you can use a command called "describe" with kubectl to learn more about the helmrelease. Here's how you can do it:</div>
|
||||
|
||||
<CodeBlock code={`kubectl describe helmrelease velero-stack -n flux-system`} /><br/>
|
||||
<div className="text">Last but not least, confirm whether the special storage space called "do-api-credentials" was created in Kubernetes. If you want to see what's inside, you can use a command like kubectl get secret do-api-credentials -n flux-system -o yaml to check the secret contents.</div>
|
||||
|
||||
<CodeBlock code={`kubectl get secret do-api-credentials -n flux-system`} /><br/>
|
||||
|
||||
<div className="text">For more detailed information about making sure Velero is working correctly, take a look at the Velero tutorial. It will provide you with additional insights into checking Velero deployment status and how it functions.</div><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion :</div> <br/>
|
||||
|
||||
<div className="text">In this guide, you discovered the foundations of automating tasks using Flux CD in a GitOps setup. You set up Flux CD to release Helm charts automatically, deploying all the Starter Kit pieces effortlessly in a GitOps style. Plus, you added an extra layer of security by using Sealed Secrets to keep sensitive information safe for your applications.</div><br/>
|
||||
|
||||
<div className="text">Ready to explore more? Check out additional resources to deepen your understanding of GitOps and automation!</div>
|
||||
351
blog/2019-05-29-blog-8.md
Normal file
@ -0,0 +1,351 @@
|
||||
---
|
||||
slug: Setting Up a LAMP Stack on Ubuntu 16.04 A Step-by-Step Guide
|
||||
title: Setting Up a LAMP Stack on Ubuntu 16.04 A Step-by-Step Guide
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import ubuntu from '@site/static/img/small_apache_default.png';
|
||||
import php_info from '@site/static/img/small_php_info.png';
|
||||
|
||||
|
||||
<div className="head">Introduction</div><br/>
|
||||
<div className="text">The LAMP stack is a combination of open-source software that works together to turn a computer into a capable server for hosting websites and web applications. Let's break it down:</div>
|
||||
<div className="text"><ul><li>L is for Linux: Linux is the operating system that our server uses</li><li>A is for Apache: Apache is the web server that helps our computer communicate with the internet and showcase our websites.</li><li>M is for MySQL: MySQL is the database where our server stores all the important data for our websites.</li><li>P is for PHP: PHP is the language that assists our server in processing and displaying dynamic content on our websites.</li></ul></div>
|
||||
|
||||
<div className="text">In this guide, we'll install the LAMP stack on an Ubuntu 16.04 server, making our computer a reliable platform for hosting websites. Ubuntu is the operating system that supports Linux in this process. Let's get started on setting up our server!</div>
|
||||
|
||||
<div className="head">Before We Start</div><br/>
|
||||
<div className="text">Before we dive into this guide, make sure you have a special user account set up on your server. This account should have the power to do extra important tasks and we'll call it the "sudo" account.</div><br/>
|
||||
|
||||
<div className="text">If you're not sure how to set up this special account, don't worry! We have a beginner-friendly tutorial that'll walk you through it. Just follow steps 1 to 4 in our "initial server setup for Ubuntu 16.04" guide. Once that's done, you'll be all set to continue with this guide. Let's get started!</div>
|
||||
|
||||
|
||||
<div className="head">Setting Up Apache and Securing Your Server</div><br/>
|
||||
|
||||
<div className="text">The Apache web server is a popular tool that helps your computer show websites to the world. It's been used for a long time and is known for doing a great job.We can easily get Apache on our computer using something called Ubuntu's "package manager." It's like an organized store where you can find and install software without any trouble. </div> <br/>
|
||||
|
||||
<div className="text">We'll also make sure our computer's security is strong by adjusting the firewall. This is like putting up a protective wall around our server to keep it safe from any potential issues on the internet. Don't worry, it's not complicated! We'll guide you through each step. Let's begin!</div><br/>
|
||||
|
||||
<div className="text">For what we're doing, you can kick things off by typing in these commands:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get update
|
||||
sudo apt-get install apache2`} /><br/>
|
||||
|
||||
<div className="text">Because we're using a special command called "sudo," these actions will be carried out with extra permissions, almost like having a superpower. It'll ask for your usual password to make sure you're the one doing it</div> <br/>
|
||||
|
||||
<div className="text">After you type your password, your computer will let you know which things it's going to install and how much extra space they'll need. Just type "y" and press ENTER to keep going, and then it'll start installing. Easy, right?</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Configuring ServerName to Avoid Syntax Warnings</div>
|
||||
|
||||
<div className="text">Next, we're going to make a quick change in a file called /etc/apache2/apache2.conf to stop a warning message. This warning is not a big deal, but it's like a little reminder from the computer. If you don't set ServerName everywhere it needs to be, the computer might give you a message when it checks for mistakes in how it's set up. We'll fix that with just one line. Let's do it!</div>
|
||||
|
||||
<CodeBlock code={`sudo apache2ctl configtest`} /><br/>
|
||||
<CodeBlock code={`Output
|
||||
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
|
||||
Syntax OK
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, let's open up the main configuration file using your text editor.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/apache2.conf`} /><br/>
|
||||
|
||||
<div className="text">Now, scroll to the bottom of the file, and add a line that tells the computer your main web address. If you don't have a special web address yet, don't worry! You can use your computer's public IP address instead. Let's make that small addition.</div><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: If you're not sure about your computer's special address on the internet, don't worry. We'll show you how to find it in the next part. Just skip ahead to that section, and we'll get it sorted out.</div>
|
||||
|
||||
<CodeBlock code={`. . .
|
||||
ServerName server_domain_or_IP
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've added that line, save the changes and close the file. It's like making sure you keep the updates you just did and shutting the door behind you. All set!</div><br/>
|
||||
|
||||
<div className="text">Now, let's see if everything looks good by typing:</div>
|
||||
|
||||
<CodeBlock code={`sudo apache2ctl configtest`} /><br/>
|
||||
|
||||
<div className="text">Now that we've added that special ServerName thing, what you should see is:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Syntax OK
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">To make everything work with your new settings, let's restart Apache. It's like giving your computer a little refresh so it can use the changes you made. Let's do it!</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl restart apache2`} /><br/>
|
||||
|
||||
<div className="text">Now, it's time to make sure our computer's protective wall (firewall) is set up correctly. Think of it like setting up a security guard for your server. Let's get started!</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Configuring the Firewall for Web Traffic</div>
|
||||
<div className="text">If you've set up the firewall following the initial server setup, now we want to ensure it allows the right kind of traffic for your website. Think of it as making sure the firewall knows to allow visitors.We'll check if the firewall has a specific setting for Apache, the web server we installed earlier, and make sure everything is configured correctly. Let's double-check and make sure everything is good to go!</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app list`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
|
||||
Available applications:
|
||||
Apache
|
||||
Apache Full
|
||||
Apache Secure
|
||||
OpenSSH
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Check the Apache Full profile, and you should see that it allows traffic to ports 80 and 443.</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw app info "Apache Full"`} /><br/>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
Profile: Apache Full
|
||||
Title: Web Server (HTTP,HTTPS)
|
||||
Description: Apache v2 is the next generation of the omnipresent Apache web
|
||||
server.
|
||||
Ports:
|
||||
80,443/tcp
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Make sure incoming traffic is allowed for this profile.</div>
|
||||
|
||||
<CodeBlock code={`sudo ufw allow in "Apache Full"`} /><br/>
|
||||
|
||||
<div className="text">You can quickly check to make sure everything is working by opening your web browser and visiting your server's public IP address. If you're not sure what your public IP address is, don't worry, we'll show you how to find it in the next section.</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_IP_address`} /><br/>
|
||||
<div className="text">When you visit your server's public IP address in the web browser, you'll see a basic page that comes with Ubuntu 16.04 and Apache. This page is there to give you information and check if everything is working well. It will look something like this</div><br/>
|
||||
|
||||
<img src={ubuntu} alt="small_apache_default" />
|
||||
|
||||
|
||||
<div className="text">If you see this page, it means your web server is set up correctly and can be reached through your firewall. Great job!</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Locating Your Server's Public IP Address</div><br/>
|
||||
|
||||
<div className="text">If you're not sure about your server's public IP address, don't worry; we can easily find it. This is the address you use to connect to your server through SSH.</div><br/>
|
||||
|
||||
<div className="text">To get this address, you can use a couple of commands from the command line. First, you can type the following to find it:</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">When you run this command, you'll see two or three lines showing different addresses. They're all correct, but your computer might only be able to use one of them. You can try each one to see which works.</div><br/>
|
||||
|
||||
<div className="text">Another way is to use a tool called curl to ask a special server what your IP address is. Here's how you can do that:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install curl
|
||||
curl http://icanhazip.com
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">No matter how you find your IP address, you can simply type it into your web browser's address bar to access your server.</div><br/>
|
||||
|
||||
<div className="head">Setting Up MySQL</div>
|
||||
<div className="text">Now that our web server is all set, let's get MySQL installed. MySQL is like a really organized system that takes care of storing and managing information for our website.</div><br/>
|
||||
|
||||
<div className="text">We'll use the same tool, apt, to easily get and install MySQL. This time, we'll also grab some extra "helper" packages to make sure all our different parts can talk to each other smoothly. Let's get started!</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install mysql-server`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: In this situation, you don't need to run a special command called sudo apt-get update before this one. We already did that a little while ago when we installed Apache. So, our computer's list of available software is already fresh and ready to go. No need to do it again!</div> <br/>
|
||||
|
||||
<div className="text">Once again, you'll see a list showing what will be installed and how much space it will take up. Just type 'Y' and press Enter to keep going.</div><br/>
|
||||
|
||||
<div className="text">While it's installing, your server will ask you to pick and confirm a password for the MySQL "root" user. This user has special privileges in MySQL. Think of it as an important password, like the main key to the server. Make sure it's a strong and unique password, and don't leave it empty. Let's get that set up!</div><br/>
|
||||
|
||||
<div className="text">Once the installation is finished, we need to run a simple security script to make sure everything is safe. This script will fix some potential problems and make our database system a bit more secure. Just run the following command to start the script:</div>
|
||||
|
||||
<CodeBlock code={`mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">You'll need to enter the password you set for the MySQL root account. Then, it'll ask if you want to set up the VALIDATE PASSWORD PLUGIN.</div><br/>
|
||||
|
||||
<div className="warn"><strong>Warning</strong>: Deciding to turn on this feature is a bit like making a choice. If you turn it on, MySQL will reject passwords that don't meet certain rules. However, this can create problems if you use a simple password with software that sets up MySQL credentials automatically, like the Ubuntu packages for phpMyAdmin. It's okay to leave this turned off, but it's really important to always use strong and unique passwords for your database.</div><br/>
|
||||
|
||||
<div className="text">Type 'y' if you want to turn it on, or type anything else if you want to continue without enabling it.</div>
|
||||
|
||||
<CodeBlock code={`VALIDATE PASSWORD PLUGIN can be used to test passwords
|
||||
and improve security. It checks the strength of password
|
||||
and allows the users to set only those passwords which are
|
||||
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
|
||||
Press y|Y for Yes, any other key for No:
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Now, it will ask you to choose a level for password validation. If you pick level 2, which is the strongest, keep in mind that you'll get errors if you try to set a password that doesn't have numbers, both uppercase and lowercase letters, special characters, or if it's based on common words. Choose the level that suits your preference and security needs.</div>
|
||||
|
||||
<CodeBlock code={`There are three levels of password validation policy:
|
||||
LOW Length >= 8
|
||||
MEDIUM Length >= 8, numeric, mixed case, and special characters
|
||||
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
|
||||
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you turned on password validation, it will show you how strong your current password is and ask if you want to change it. If you like your current password, just type 'n' for "no" when it asks.</div>
|
||||
|
||||
<CodeBlock code={`Using existing password for root.
|
||||
Estimated strength of the password: 100
|
||||
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">For the other questions, just press 'Y' and then hit the Enter key each time it asks. This will get rid of some extra users and a test database, stop remote root logins, and apply these new rules right away so MySQL follows the changes we made.</div> <br/>
|
||||
|
||||
<div className="text">Now, your database system is all ready, and we can move on to the next steps.</div>
|
||||
|
||||
<div className="head">Configuring PHP</div><br/>
|
||||
|
||||
<div className="text">PHP is like the part of our setup that makes things happen on our website. It's the one that takes care of running special codes, talking to our MySQL databases to get information, and then handing over the processed content to our web server so it can show up on the website.</div><br/>
|
||||
|
||||
<div className="text">To make it work, we'll use the apt system again to install PHP and some helper packages. These helpers make sure that PHP and the Apache server can work together smoothly and talk to our MySQL database. Let's get it set up!</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql`} /><br/>
|
||||
|
||||
<div className="text">Installing PHP is usually straightforward. We'll check to make sure everything's okay soon.</div>
|
||||
|
||||
<div className="text">Usually, when someone asks for a folder on our server, Apache looks for a file named index.html first. But we want to make Apache look for index.php files instead. It's like telling the server to prefer PHP files over HTML files.</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/mods-enabled/dir.conf
|
||||
<IfModule mod_dir.c>
|
||||
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">We want to make sure our server looks for PHP files first when someone asks for a folder. To do this, we'll move the PHP index file we talked about earlier to the top of the list after the "DirectoryIndex" instruction. It's like telling the server, "Hey, check for PHP files first!</div>
|
||||
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c>
|
||||
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">When you're done, save and close the file by pressing Ctrl-X. Confirm the save by typing 'Y' and press Enter.</div><br/>
|
||||
|
||||
<div className="text">After that, we need to restart the Apache web server so it recognizes the changes we made. You can do this by typing the following command:</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl restart apache2`} /><br/>
|
||||
|
||||
<div className="text">We can also see how things are going with the Apache web server by using a command called systemctl.</div>
|
||||
|
||||
<CodeBlock code={`sudo systemctl status apache2`} /><br/>
|
||||
|
||||
|
||||
<CodeBlock code={`Sample Output
|
||||
● apache2.service - LSB: Apache2 web server
|
||||
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
|
||||
Drop-In: /lib/systemd/system/apache2.service.d
|
||||
└─apache2-systemd.conf
|
||||
Active: active (running) since Wed 2016-04-13 14:28:43 EDT; 45s ago
|
||||
Docs: man:systemd-sysv-generator(8)
|
||||
Process: 13581 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
|
||||
Process: 13605 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
|
||||
Tasks: 6 (limit: 512)
|
||||
CGroup: /system.slice/apache2.service
|
||||
├─13623 /usr/sbin/apache2 -k start
|
||||
├─13626 /usr/sbin/apache2 -k start
|
||||
├─13627 /usr/sbin/apache2 -k start
|
||||
├─13628 /usr/sbin/apache2 -k start
|
||||
├─13629 /usr/sbin/apache2 -k start
|
||||
└─13630 /usr/sbin/apache2 -k start
|
||||
Apr 13 14:28:42 ubuntu-16-lamp systemd[1]: Stopped LSB: Apache2 web server.
|
||||
Apr 13 14:28:42 ubuntu-16-lamp systemd[1]: Starting LSB: Apache2 web server...
|
||||
Apr 13 14:28:42 ubuntu-16-lamp apache2[13605]: * Starting Apache httpd web server apache2
|
||||
Apr 13 14:28:42 ubuntu-16-lamp apache2[13605]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerNam
|
||||
Apr 13 14:28:43 ubuntu-16-lamp apache2[13605]: *
|
||||
Apr 13 14:28:43 ubuntu-16-lamp systemd[1]: Started LSB: Apache2 web server.
|
||||
`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Adding Extra Features to PHP</div>
|
||||
<div className="text">If you want to make PHP even more powerful, you can choose to install some extra features called modules.</div><br/>
|
||||
|
||||
<div className="text">To see what's available, think of it like checking a menu – you can look at all the options using a command called apt-cache search. It's a bit like exploring a menu and then scrolling through it with a tool called less. Let's check it out</div>
|
||||
|
||||
<CodeBlock code={`apt-cache search php- | less`} /><br/>
|
||||
|
||||
<div className="text">You can use the arrow keys to move up and down, and press 'q' when you're done to exit.</div><br/>
|
||||
|
||||
<div className="text">These results show you extra things you can add if you want. Each one has a short description to help you understand what it does.</div>
|
||||
|
||||
<CodeBlock code={`libnet-libidn-perl - Perl bindings for GNU Libidn
|
||||
php-all-dev - package depending on all supported PHP development packages
|
||||
php-cgi - server-side, HTML-embedded scripting language (CGI binary) (default)
|
||||
php-cli - command-line interpreter for the PHP scripting language (default)
|
||||
php-common - Common files for PHP packages
|
||||
php-curl - CURL module for PHP [default]
|
||||
php-dev - Files for PHP module development (default)
|
||||
php-gd - GD module for PHP [default]
|
||||
php-gmp - GMP module for PHP [default]
|
||||
…
|
||||
:
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To find out more about what each module does, you can either search on the internet or check the detailed description of the package by typing:</div>
|
||||
|
||||
<CodeBlock code={`apt-cache show package_name`} /><br/>
|
||||
|
||||
<div className="text">When you run this command, you'll see a lot of information. Look for a field called "Description-en" – it has a longer explanation of what each module does.</div>
|
||||
|
||||
<div className="text">For instance, if you want to know more about the php-cli module, you can type this:</div>
|
||||
|
||||
<CodeBlock code={`apt-cache show php-cli`} /><br/>
|
||||
|
||||
<div className="text">Among the information shown, you'll find something that looks like this:</div>
|
||||
|
||||
<CodeBlock code={`Output
|
||||
…
|
||||
Description-en: command-line interpreter for the PHP scripting language (default)
|
||||
This package provides the /usr/bin/php command interpreter, useful for
|
||||
testing PHP scripts from a shell or performing general shell scripting tasks.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
.
|
||||
This package is a dependency package, which depends on Debian's default
|
||||
PHP version (currently 7.0).
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If you've done your research and want to add a package, you can do that using the same command we've used to install other software.</div>
|
||||
|
||||
<div className="text">For instance, if you've decided that you need php-cli, you can type:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install php-cli`} /><br/>
|
||||
|
||||
<div className="text">Now, your LAMP stack is all set up and ready to go. However, let's make sure PHP is working properly by doing a quick test.</div><br/>
|
||||
|
||||
<div className="head">Trying Out PHP on Your Website Server</div>
|
||||
|
||||
<div className="text">To make sure everything is set up right for PHP, we'll make a simple PHP script.<br/>
|
||||
Let's name this script info.php. To make sure Apache can find and show it correctly, we need to save it in a special folder called the web root<br/>On Ubuntu 16.04, this folder is at /var/www/html/. We can put the file there by typing:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">This will open a new empty file. We'll then add some code into it, which is proper PHP language. Here's what we need to add:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
phpinfo();
|
||||
?>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you're done, save the file and close it.<br/>
|
||||
Now, let's see if our web server can show what our PHP script generates. To check, we just need to go to a specific page in our web browser. You'll need your server's public IP address again.<br/>
|
||||
The page you want to go to is:</div>
|
||||
|
||||
<CodeBlock code={`http://your_server_IP_address/info.php`} /><br/>
|
||||
|
||||
<div className="text">The page you'll see should look a bit like this:</div>
|
||||
|
||||
<img src={php_info} alt="small_php_info" /><br/>
|
||||
|
||||
<div className="text">This page gives you info about your server using PHP. It's handy for checking things and making sure your settings are right.</div><br/>
|
||||
|
||||
<div className="text">If it worked, your PHP is doing what it should.</div><br/>
|
||||
|
||||
|
||||
<div className="text">After this test, it's a good idea to delete this file because it might reveal info about your server to people who shouldn't see it. To delete it, just type:</div>
|
||||
|
||||
<CodeBlock code={`sudo rm /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">If you ever need the info again, you can always make this page once more.</div> <br/>
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
|
||||
<div className="text">Now that you've set up a LAMP stack, you're ready to do a lot of cool stuff! Basically, you've got a system that lets you install many different types of websites and web tools on your server. But before you go further, it's important to make sure your website is secure. That means making sure people can connect to it safely using HTTPS. The easiest way to do this is by using Let’s Encrypt. They offer a free TLS/SSL certificate to secure your site.</div><br/>
|
||||
|
||||
<div className="text"><strong>Ready to secure your website? Get started with Let’s Encrypt now!</strong></div>
|
||||
235
blog/2019-05-29-blog-9.md
Normal file
@ -0,0 +1,235 @@
|
||||
---
|
||||
slug: Setting Up a Web Server with Linux Apache MySQL PHP
|
||||
title: Setting Up a Web Server with Linux, Apache, MySQL, PHP (LAMP) on Ubuntu 14.04
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import ubuntu from '@site/static/img/small_apache_default.png';
|
||||
|
||||
<div className="head">Introduction</div><br/>
|
||||
<div className="text">A "LAMP" stack is like a set of tools for building websites and web apps. It's made up of different free software that work together on a computer server. Let's look at what each part does:</div>
|
||||
|
||||
<div className="text"><ol><li>Operating System: This is like the main software that runs everything on the computer. It's the foundation of the stack.</li><li>Web Server (Apache): Apache acts like a traffic controller for the web. It takes requests from people's browsers and sends back the right web pages.</li><li>Database (MySQL): This is where all the website's data is stored, like usernames, passwords, and other information. It's like a digital filing cabinet.</li><li>Server-side Language (PHP): PHP is a language that helps create dynamic web pages. It's what makes things like logins, forms, and shopping carts work smoothly.</li></ol></div>
|
||||
|
||||
<div className="text">Now, let's learn how to set up this LAMP stack on a computer running Ubuntu 14.04. Ubuntu is just another type of operating system and it's perfect for this task.</div><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: Installing a LAMP stack on your Droplet can be made super easy! Just include this special script when you're setting up your Droplet. It's like giving your computer a set of instructions to follow right from the start. If you're not sure how to do this, check out the tutorial on Droplet User Data. It'll walk you through the process step by step.</div> <br/>
|
||||
|
||||
<div className="head">Getting Started</div>
|
||||
<div className="text">Before you start following this guide, make sure you have a special user account set up on your server. This account shouldn't be the main "root" one, but it should have similar privileges. If you're not sure how to set up this user account, you can check out steps 1-4 in the beginner's guide for setting up your server with Ubuntu 14.04. It'll walk you through the process in easy-to-follow steps.</div><br/>
|
||||
|
||||
<div className="head">Let's Get Your Website Running: Installing Apache</div>
|
||||
<div className="text">Apache is like the engine that powers many websites on the internet. It's super popular and reliable, making it a great choice for hosting your site.To get Apache, we'll use something called Ubuntu's "package manager." It's like an app store for your server!</div><br/>
|
||||
|
||||
<div className="text">Here's how we do it: We just tell the package manager what we want, and it goes and gets it for us. Easy, right? If you want to learn more about how it works, you can check out this guide on using the package manager.</div>
|
||||
|
||||
|
||||
<CodeBlock code={`sudo apt-get update
|
||||
sudo apt-get install apache2
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="text">When we use a command with "sudo," it means we're doing something important with extra powers. It might ask for your regular password just to make sure you're sure about what you're doing.</div><br/>
|
||||
|
||||
<div className="text">Once we're done with that, our web server is good to go!</div><br/>
|
||||
|
||||
<div className="text">To make sure everything worked like it should, you can quickly check it by going to your server's public IP address in your web browser. If you're not sure what that is, don't worry, we'll show you how to find it in the next part.</div>
|
||||
|
||||
<CodeBlock code={`<pre> http://<span class=“highlight”>your_server_IP_address</span> </pre>`} /><br/>
|
||||
|
||||
<div className="text">You'll be greeted with a special webpage made by Apache on Ubuntu 14.04. It's there to give you some basic info and to help you check if everything is working fine. It might look a bit like this:</div>
|
||||
|
||||
<img src={ubuntu} alt="small_apache_default" />
|
||||
|
||||
<div className="text">How to See Your Server's Public IP Address:
|
||||
If you're not sure what your server's public IP address is, there are a few simple ways to find it. This is the address you use to connect to your server using SSH.</div> <br/>
|
||||
|
||||
<div className="text">One way to find it is by using commands on the command line. You can do this by typing a specific command, like this:</div>
|
||||
|
||||
<CodeBlock code={`ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'`} /><br/>
|
||||
|
||||
<div className="text">After running the command, you'll see one or two lines with numbers on them. Both lines show the correct addresses, but your computer might only be able to use one of them. So, you can try using each one to see which works.</div><br/>
|
||||
|
||||
<div className="text">Another way is to ask a different computer outside of your network to tell you what it sees as your server's IP address. You can do this by reaching out to a specific server and asking it for the information.</div>
|
||||
|
||||
<CodeBlock code={`curl http://icanhazip.com`} /><br/>
|
||||
|
||||
<div className="text">No matter how you find your IP address, you can simply type it into your web browser's address bar to reach your server.</div>
|
||||
|
||||
<div className="head">Setting Up MySQL Database Management System</div>
|
||||
|
||||
<div className="text">Let's set up MySQL now that our web server is running. MySQL is like a storage system for our website. It helps organize and manage databases where our site can keep information.</div><br/>
|
||||
|
||||
<div className="text">We'll use a tool called "apt" to get and install MySQL, just like before. This time, we'll also install some extra packages that help different parts of our setup talk to each other:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install mysql-server php5-mysql`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: You don't need to run "sudo apt-get update" again before installing MySQL because we already did that when installing Apache. Your computer already has the latest information about available packages.</div> <br/>
|
||||
|
||||
<div className="text">While installing MySQL, your server will ask you to pick and confirm a password for the MySQL "root" user. This is like an administrator account in MySQL, with special powers. It's similar to the main account for the server itself, but just for MySQL.</div><br/>
|
||||
|
||||
<div className="text">After MySQL is installed, we have to do a few more things to make sure it's set up safely.<br/><br/>
|
||||
First, we need to tell MySQL to create the place where it will keep all its information. You can do this by typing:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_install_db`} /><br/>
|
||||
|
||||
<div className="text">After that, we'll run a simple security script to make sure our database system is safer. To begin this script, just run:</div>
|
||||
|
||||
<CodeBlock code={`sudo mysql_secure_installation`} /><br/>
|
||||
|
||||
<div className="text">You'll be prompted to enter the password you set for the MySQL root account. Then, it will ask if you want to change that password. If you're happy with it, just type "n" for "no".</div><br/>
|
||||
|
||||
<div className="text">For the other questions, just press "ENTER" to accept the default values. This will remove some sample users and databases, disable remote root logins, and apply these new rules immediately to MySQL.<br/>
|
||||
Now your database system is all set up and we can move forward.</div>
|
||||
|
||||
<div className="head">Installing PHP for Dynamic Website Content</div>
|
||||
<div className="text">Let's install PHP, which is a crucial part of our setup. PHP is responsible for processing code to show dynamic content on our website. It can run scripts, communicate with our MySQL databases to fetch information, and then deliver the processed content to our web server for display.</div><br/>
|
||||
|
||||
<div className="text">We'll use the apt system again to install PHP along with some additional helper packages.</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt`} /><br/>
|
||||
|
||||
<div className="text">Installing PHP should be smooth without encountering any issues. We'll verify this shortly.</div><br/>
|
||||
|
||||
<div className="text">Usually, we'll want to adjust how Apache handles files when someone requests a directory from our server. Right now, if a user asks for a directory, Apache checks if there's a file called "index.html" inside. However, we prefer to use PHP files, so we'll tell Apache to look for an "index.php" file first.</div><br/>
|
||||
|
||||
<div className="text">To make this change, follow these steps - Open the "dir.conf" file in a text editor with special permissions. You can do this by typing:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /etc/apache2/mods-enabled/dir.conf`} /><br/>
|
||||
|
||||
<div className="text">Here's what the file will look like:</div>
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c>
|
||||
DirectoryIndex index.html index.cgi index.pl <span class=“highlight”>index.php</span> index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">We want to move the highlighted PHP index file to the first position after the DirectoryIndex specification, like this:</div>
|
||||
|
||||
<CodeBlock code={`<IfModule mod_dir.c>
|
||||
DirectoryIndex <span class=“highlight”>index.php</span> index.html index.cgi index.pl index.xhtml index.htm
|
||||
</IfModule>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you've made this change, save and close the file by pressing "CTRL-X". Confirm the save by typing "Y" and then hit "ENTER" to confirm the file save location.</div><br/>
|
||||
|
||||
<div className="text">After that, we need to restart the Apache web server to make our changes take effect. You can do this by typing:</div>
|
||||
|
||||
<CodeBlock code={`sudo service apache2 restart`} /><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Enhancing PHP Functionality with Additional Modules</div>
|
||||
<div clssName="text">We can make PHP even more powerful by adding extra modules. These modules provide additional features and tools that we can use in our PHP code.</div><br/>
|
||||
|
||||
<div className="text">To check out the available options for PHP modules and libraries, you can do this:</div>
|
||||
|
||||
<CodeBlock code={`apt-cache search php5-`} /><br/>
|
||||
|
||||
<div className="text">The list shows extra parts you can add if you want. Each one comes with a quick explanation:</div>
|
||||
|
||||
<CodeBlock code={`php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
|
||||
php5-cli - command-line interpreter for the php5 scripting language
|
||||
php5-common - Common files for packages built from the php5 source
|
||||
php5-curl - CURL module for php5
|
||||
php5-dbg - Debug symbols for PHP5
|
||||
php5-dev - Files for PHP5 module development
|
||||
php5-gd - GD module for php5
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">To learn more about what each module does, you have two options:</div>
|
||||
<div className="text"><ol><li>Search online.</li><li>Check the detailed description in the package itself. You can do this by typing:</li></ol></div>
|
||||
|
||||
<CodeBlock code={`apt-cache show <span class=“highlight”>package_name</span>`} /><br/>
|
||||
|
||||
<div className="text">This will show a lot of information, but focus on the "Description-en" field, which gives a longer explanation of what the module does.</div><br/>
|
||||
|
||||
<div className="text">For instance, to find out about the php5-cli module, you can type:</div>
|
||||
|
||||
<CodeBlock code={`apt-cache show php5-cli`} /><br/>
|
||||
|
||||
<div className="text">In addition to many other details, you'll see something like this:</div>
|
||||
|
||||
<CodeBlock code={`. . .
|
||||
SHA256: 91cfdbda65df65c9a4a5bd3478d6e7d3e92c53efcddf3436bbe9bbe27eca409d
|
||||
Description-en: command-line interpreter for the php5 scripting language
|
||||
This package provides the /usr/bin/php5 command interpreter, useful for
|
||||
testing PHP scripts from a shell or performing general shell scripting tasks.
|
||||
.
|
||||
The following extensions are built in: bcmath bz2 calendar Core ctype date
|
||||
dba dom ereg exif fileinfo filter ftp gettext hash iconv libxml mbstring
|
||||
mhash openssl pcntl pcre Phar posix Reflection session shmop SimpleXML soap
|
||||
sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader
|
||||
xmlwriter zip zlib.
|
||||
.
|
||||
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
|
||||
open source general-purpose scripting language that is especially suited
|
||||
for web development and can be embedded into HTML.
|
||||
Description-md5: f8450d3b28653dcf1a4615f3b1d4e347
|
||||
Homepage: http://www.php.net/
|
||||
. . .
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">If, after checking, you decide you want to add a package, you can use the "apt-get install" command just like we did for our other software.</div><br/>
|
||||
|
||||
<div className="text">For example, if you've decided you need "php5-cli", you would type:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install php5-cli`} /><br/>
|
||||
|
||||
<div className="text">If you want to install multiple modules, you can do that by listing each one, separated by a space, after the "apt-get install" command, like this:</div>
|
||||
|
||||
<CodeBlock code={`sudo apt-get install <span class=“highlight”>package1</span> <span class=“highlight”>package2</span> <span class=“highlight”>…</span>`} /><br/>
|
||||
|
||||
<div className="text">Now, your LAMP stack is all set up and ready to go. However, we should still check if PHP is working correctly.</div>
|
||||
|
||||
|
||||
<div className="head">Checking PHP Functionality on Your Web Server</div>
|
||||
|
||||
<div className="text">To make sure our system is set up correctly for PHP, let's create a simple PHP script.<br/><br/>
|
||||
We'll name this script "info.php". For Apache to find and display the file properly, it needs to be saved in a specific folder called the "web root".<br/><br/>
|
||||
In Ubuntu 14.04, this folder is located at "/var/www/html/". You can create the file in that location by typing:</div>
|
||||
|
||||
<CodeBlock code={`sudo nano /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">This will open an empty file. Now, we'll add some simple PHP code inside it. Just copy and paste the following text into the file:</div>
|
||||
|
||||
<CodeBlock code={`<?php
|
||||
phpinfo();
|
||||
?>
|
||||
`} /><br/>
|
||||
|
||||
<div className="text">Once you're done, save and close the file.</div><br/>
|
||||
|
||||
<div className="text">Now, let's check if our web server can show content generated by a PHP script. To do this, simply open your web browser and visit the following page. You'll need your server's public IP address again.</div><br/>
|
||||
|
||||
<div className="text">The address you want to visit is:</div>
|
||||
|
||||
<CodeBlock code={`http://<span class=“highlight”>your_server_IP_address</span>/info.php`} /><br/>
|
||||
|
||||
<div className="text">When you go to this page, you should see something similar to this:</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <needs to add image here> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="text">This page shows you server information from PHP's perspective, useful for checking your setup. If everything looks good, your PHP is working as it should.</div> <br/>
|
||||
|
||||
<div className="text">If everything went well and you see the expected information, it means your PHP is working correctly.</div>
|
||||
|
||||
<div className="text">However, you should consider removing this file after the test because it could potentially expose information about your server to unauthorized users. To delete it, you can do the following:</div>
|
||||
|
||||
<CodeBlock code={`sudo rm /var/www/html/info.php`} /><br/>
|
||||
|
||||
<div className="text">If you ever need to check that information again, you can always recreate this page.</div><br/>
|
||||
|
||||
|
||||
<div className="con">Conclusion:</div>
|
||||
<div className="text">Now that you've set up your LAMP stack, you're ready to do a lot of cool stuff! Basically, you've got everything you need to create different types of websites and web software on your server.There are so many possibilities! Just choose what interests you the most and start exploring.</div>
|
||||
119
blog/2019-05-29-first-blog-post.md
Normal file
@ -0,0 +1,119 @@
|
||||
---
|
||||
slug: SOLID Unveiling the Initial 5 Principles of Object-Oriented Design
|
||||
title: SOLID Unveiling the Initial 5 Principles of Object-Oriented Design
|
||||
authors: [slorber]
|
||||
tags: [hola, docusaurus]
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
<div className="text">Welcome to the world of SOLID, a set of five fundamental principles in Object-Oriented Design (OOD) coined by Robert C. Martin, lovingly known as Uncle Bob. <br/><br/>
|
||||
<div style={{ marginTop: '-16px'}}> Before we dive in, it's important to know that while these principles are applicable across different programming languages, our examples here will be using PHP.</div> <br/>
|
||||
<span style={{ marginTop: '-16px' , fontSize: '24px' , fontFamily: 'Open Sans' , fontWeight: '700' }}>Now, let's break down SOLID: </span> <br/> <br/>
|
||||
<span className="custom-text">S - Single-responsibility Principle </span> <br/>
|
||||
This principle encourages each part of your code to have just one job. It makes things simpler to understand and maintain.<br/> <br/>
|
||||
<span className="custom-text">O - Open-closed Principle </span> <br/>
|
||||
The open-closed principle suggests that your code should be open for extension but closed for modification. In simpler terms, you can add new features without changing existing code. <br/> <br/>
|
||||
<span className="custom-text">L - Liskov Substitution Principle</span> <br/>
|
||||
This principle deals with using derived classes that can be substituted for their base classes without affecting the program's functionality. It promotes consistency and reliability. <br/> <br/>
|
||||
<span className="custom-text">I - Interface Segregation Principle</span> <br/>
|
||||
The interface segregation principle advises breaking down large interfaces into smaller, more specific ones. This makes it easier for classes to implement only what they need. <br/> <br/>
|
||||
<span className="custom-text">D - Dependency Inversion Principle</span> <br/>
|
||||
This principle emphasizes relying on abstractions rather than concretions. It helps in creating flexible and scalable systems. <br/> <br/>
|
||||
In the upcoming sections, we'll explore each of these principles individually. By understanding and applying SOLID, you'll not only become a better developer but also enhance your ability to create software that's easy to maintain and expand as your project grows </div> <br/>
|
||||
<br/>
|
||||
<span className="head" >Single-responsibility Principle: </span>
|
||||
<br/>
|
||||
|
||||
<CodeBlock code={`class Painter:
|
||||
def color_shape(self, shape):
|
||||
# Code for coloring the shape
|
||||
pass`} />
|
||||
|
||||
<!-- class Painter:
|
||||
def color_shape(self, shape):
|
||||
# Code for coloring the shape
|
||||
pass -->
|
||||
|
||||
|
||||
<br/>
|
||||
<span className="head" >Open-closed Principle:</span>
|
||||
|
||||
|
||||
<CodeBlock code={`class Painter:
|
||||
def color_shape(self, shape):
|
||||
# Code for coloring the shape
|
||||
class ShapeDrawer:
|
||||
def draw_shapes(self, shapes):
|
||||
for shape in shapes:
|
||||
shape.draw()
|
||||
pass`} />
|
||||
|
||||
|
||||
<CodeBlock code={`class Painter:
|
||||
def color_shape(self, shape):
|
||||
# Code for coloring the shape
|
||||
class ShapeDrawer:
|
||||
def draw_shapes(self, shapes):
|
||||
for shape in shapes:
|
||||
shape.draw()
|
||||
pass`} />
|
||||
|
||||
<CodeBlock code={`class Square:
|
||||
def draw(self):
|
||||
# Code for drawing a square
|
||||
pass`} />
|
||||
|
||||
<CodeBlock code={`class Circle:
|
||||
def draw(self):
|
||||
# Code for drawing a circle
|
||||
pass `} /> <br/>
|
||||
|
||||
|
||||
|
||||
<span className="head" >Liskov Substitution Principle: </span>
|
||||
|
||||
<CodeBlock code={`class ResizableCircle(Circle):
|
||||
def resize(self, factor):
|
||||
# Code for resizing the circle
|
||||
pass `} /> <br/>
|
||||
|
||||
|
||||
|
||||
<span className="head" >Interface Segregation Principle:</span>
|
||||
|
||||
<CodeBlock code={` class TextPrintable:
|
||||
def print_text(self):
|
||||
# Code for printing text
|
||||
pass `} />
|
||||
|
||||
<CodeBlock code={`class ImagePrintable:
|
||||
def print_image(self):
|
||||
# Code for printing an image
|
||||
pass `} /> <br/>
|
||||
|
||||
|
||||
<span className="head" >Dependency Inversion Principle:</span>
|
||||
|
||||
<CodeBlock code={`class APIConnector:
|
||||
def connect(self):
|
||||
# Code for connecting to the API
|
||||
pass `} />
|
||||
|
||||
<CodeBlock code={`class App:
|
||||
def __init__(self, api_connector):
|
||||
self.api_connector = api_connector
|
||||
|
||||
def perform_operation(self):
|
||||
# Code using the API connector without knowing its specific implementation
|
||||
self.api_connector.connect() `} />
|
||||
<br/>
|
||||
<span className="con">Conclusion - </span>
|
||||
|
||||
<div className="text">SOLID principles are like a set of guidelines that help you write code that's easy to understand, modify, and expand. They encourage you to create classes with one clear purpose, add new features without breaking existing code, ensure consistency in your code, focus on what each class needs to do, and rely on abstractions for flexibility.
|
||||
By applying these principles, you'll be on your way to becoming a better and more efficient coder. Happy coding! </div>
|
||||
|
||||
47
blog/authors.yml
Normal file
@ -0,0 +1,47 @@
|
||||
# yangshun:
|
||||
# name: Yangshun Tay
|
||||
# title: Front End Engineer @ Facebook
|
||||
# url: https://github.com/yangshun
|
||||
# image_url: https://git.tech4biz.wiki/yashwin/image/src/branch/main/pic.png
|
||||
# page: true
|
||||
# socials:
|
||||
# x: yangshunz
|
||||
# github: yangshun
|
||||
|
||||
# slorber:
|
||||
# name: Yashwin Shankar
|
||||
# title: Front End developer @Tech4Biz
|
||||
# url: https://sebastienlorber.com
|
||||
# image_url: /static/img/pic.png
|
||||
# page:
|
||||
# # customize the url of the author page at /blog/authors/<permalink>
|
||||
# permalink: '/all-sebastien-lorber-articles'
|
||||
# socials:
|
||||
# x: sebastienlorber
|
||||
# linkedin: sebastienlorber
|
||||
# github: slorber
|
||||
# newsletter: https://thisweekinreact.com
|
||||
|
||||
|
||||
# yangshun:
|
||||
# name: Yangshun Tay
|
||||
# title: Front End Engineer @ Facebook
|
||||
# url: https://github.com/yangshun
|
||||
# image_url: https://github.com/yangshun.png
|
||||
# page: true
|
||||
# socials:
|
||||
# x: yangshunz
|
||||
# github: yangshun
|
||||
|
||||
slorber:
|
||||
name: Yashwin Shankar
|
||||
title: Front End Developer @ Tech4Biz
|
||||
url: https://sebastienlorber.com
|
||||
image_url: https://git.tech4biz.wiki/yashwin/image/raw/branch/main/pic.png
|
||||
|
||||
page:
|
||||
permalink: '/all-sebastien-lorber-articles'
|
||||
socials:
|
||||
linkedin: yashwin-ms
|
||||
github: yashwin-foxy
|
||||
# newsletter: https://thisweekinreact.com
|
||||
19
blog/tags.yml
Normal file
@ -0,0 +1,19 @@
|
||||
facebook:
|
||||
label: Facebook
|
||||
permalink: /facebook
|
||||
description: Facebook tag description
|
||||
|
||||
hello:
|
||||
label: Hello
|
||||
permalink: /hello
|
||||
description: Hello tag description
|
||||
|
||||
docusaurus:
|
||||
label: Docusaurus
|
||||
permalink: /docusaurus
|
||||
description: Docusaurus tag description
|
||||
|
||||
hola:
|
||||
label: Hola
|
||||
permalink: /hola
|
||||
description: Hola tag description
|
||||
BIN
create-container.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
52
docs/CloudtopiaaInstances/Manage Images.md
Normal file
@ -0,0 +1,52 @@
|
||||
---
|
||||
sidebar_label: "Manage Images"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import image01 from '@site/static/img/image01.png';
|
||||
import image02 from '@site/static/img/image02.png';
|
||||
|
||||
|
||||
# Manage Images
|
||||
|
||||
<div className="head">Upload Image</div>
|
||||
<div className="text">Follow this procedure to upload an image to a project:</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left<br/> <br/><img src={image01} alt="images" /><br/><br/></li><li>Navigate to <span className="blue">Project</span> > <span className="blue"> Images</span> and click<span className="blue"> Create Image.</span></li><br/><li>Enter the following values:</li></ol></div>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Image Name</td>
|
||||
<td>Enter a name for the image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image Source</td>
|
||||
<td>Choose the image source from the dropdown list. Your choices are Image Location and Image File</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Format</td>
|
||||
<td>Select the image format (for example, QCOW2) for the image</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Protected</td>
|
||||
<td>Select this check box to ensure that only users with permissions can delete the image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Visibility</td>
|
||||
<td>Select Image visibility. Default is shared</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table><br/><br/>
|
||||
|
||||
|
||||
|
||||
<img src={image02} alt="images" /><br/><br/>
|
||||
|
||||
<div className="text">5. Click <span className="blue">Create Image</span>. The image is queued to be uploaded. It might take some time before the status changes from <span className="blue">Queued</span> to <span className="blue">Active</span>.</div>
|
||||
|
||||
|
||||
|
||||
143
docs/CloudtopiaaInstances/Manage Instances.md
Normal file
@ -0,0 +1,143 @@
|
||||
---
|
||||
sidebar_label: "Manage Instances"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import mi01 from '@site/static/img/mi-01.png';
|
||||
import in01 from '@site/static/img/in01.png';
|
||||
import in02 from '@site/static/img/in02.png';
|
||||
import in03 from '@site/static/img/in03.png';
|
||||
import in04 from '@site/static/img/in04.png';
|
||||
import in05 from '@site/static/img/in05.png';
|
||||
import in06 from '@site/static/img/in06.png';
|
||||
import in07 from '@site/static/img/in07.png';
|
||||
import in08 from '@site/static/img/in08.png';
|
||||
import in09 from '@site/static/img/in09.png';
|
||||
import in10 from '@site/static/img/in10.png';
|
||||
import in11 from '@site/static/img/in11.png';
|
||||
import in12 from '@site/static/img/in12.png';
|
||||
import in13 from '@site/static/img/in13.png';
|
||||
import in14 from '@site/static/img/in14.png';
|
||||
|
||||
|
||||
|
||||
# Manage Instances
|
||||
|
||||
<div className="head">Create Instance</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left</li></ol></div>
|
||||
|
||||
|
||||
<img src={mi01} alt="Manage Instance" /><br/><br/>
|
||||
|
||||
<div className="text">3. . Navigate to <span className="blue">Project</span> > <span className="blue">Compute</span> > <span className="blue">Instances</span> and click <span className="blue">Launch Instance</span> </div><br/>
|
||||
|
||||
<div className="text">4. Specify following details in <span className="blue">Details tab</span> and click <span className="blue">Next.</span></div><br/>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Instance Name</td>
|
||||
<td>Assign a name to the virtual machine</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Count</td>
|
||||
<td>Number of virtual machines to launch with identical specs. Default is 1.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
|
||||
|
||||
<img src={in01} alt="Instance" /><br/><br/>
|
||||
.
|
||||
<div className="text">Specify following details in <span className="blue">Source</span> tab and click <span className="blue">Next</span></div><br/>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Boot Source</td>
|
||||
<td>Available options are image, volume and snapshots. Default is image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Volume Size </td>
|
||||
<td>Size of root volume</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image Name </td>
|
||||
<td>This field changes based on your Boost Source selection. If you have chosen to
|
||||
launch an instance using an image, the Image Name field displays. Select the
|
||||
image name from the dropdown list.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
|
||||
<img src={in02} alt="Instance" /><br/><br/>
|
||||
|
||||
<img src={in03} alt="Instance" /><br/><br/>
|
||||
|
||||
<div clssName="text">6. Specify the size of the instance to launch in <span className="blue">Flavor</span> tab and click <span className="blue"> Next.</span></div><br/>
|
||||
|
||||
<img src={in04} alt="Instance" /><br/><br/>
|
||||
|
||||
<div className="text">7. Select <span className="blue"> Network</span> and click <span className="blue"> Next</span> </div><br/>
|
||||
|
||||
<img src={in05} alt="Instance" /><br/><br/>
|
||||
|
||||
<div className="text">8. Select <span className="blue">Security Group(s)</span> and click <span className="blue">Next.</span> </div> <br/>
|
||||
|
||||
<img src={in06} alt="Instance" /><br/><br/>
|
||||
|
||||
|
||||
<div className="text">9. Select <span className="blue">Key Pair</span> and click <span className="blue">Launch Instance</span></div><br/>
|
||||
|
||||
|
||||
|
||||
<img src={in07} alt="Instance" /><br/><br/>
|
||||
|
||||
<div className="text">10. Instance will take few minutes to configure depending on size of the image being used</div><br/>
|
||||
|
||||
|
||||
|
||||
<img src={in08} alt="Instance" /><br/><br/>
|
||||
|
||||
|
||||
<div className="head">Connect to Instance</div>
|
||||
<div className="text"><ol><li>Navigate to <span className="blue">Project</span> > <span className="blue">Compute</span> > <span className="blue">Instances</span> </li><li>Open on the instance dropdown and click on <span className="blue">Associate Floating IP</span> </li></ol></div><br/>
|
||||
|
||||
<img src={in09} alt="Instance" /><br/><br/>
|
||||
|
||||
<div className="text">3. If there are no Floating IP Addresses are reserved before, we will get 'No floating IP addresses
|
||||
allocated' in <span className="blue">IP Address</span> dropdown.</div><br/>
|
||||
|
||||
|
||||
|
||||
<img src={in10} alt="Instance" /><br/><br/>
|
||||
|
||||
<div className="text">4. In case there are no FIP Addresses reserved, click on <span className="blue"> + </span> sign and in <span className="text">Allocate Floating IP</span> dialog box click <span className="blue"> Allocate IP.</span></div><br/>
|
||||
|
||||
<img src={in11} alt="Instance" /><br/><br/>
|
||||
|
||||
<div className="text">5. Now we will be redirected back to <span className="blue"> Manage Floating IP Association </span> dialog box. Select public IP from IP Address dropdown and server private network port in <span className="blue"> Port to be associated </span> dropdown and click
|
||||
<span className="blue">on Associate</span></div><br/>
|
||||
|
||||
|
||||
|
||||
<img src={in12} alt="Instance" /><br/><br/>
|
||||
|
||||
<div className="text">6. Instance now have public IP associated.</div><br/>
|
||||
|
||||
<img src={in13} alt="Instance" /><br/><br/>
|
||||
|
||||
<div className="text">. Instance can be access through public IP if the communication is allowed in security group.</div><br/>
|
||||
|
||||
<img src={in14} alt="Instance" /><br/><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
23
docs/CloudtopiaaInstances/Manage Key Pairs.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
sidebar_label: 'Manage Key Pairs'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import key01 from '@site/static/img/key01.png';
|
||||
import key02 from '@site/static/img/key02.png';
|
||||
import key03 from '@site/static/img/key03.png';
|
||||
import key04 from '@site/static/img/key04.png';
|
||||
import key05 from '@site/static/img/key05.png';
|
||||
import key06 from '@site/static/img/key06.png';
|
||||
|
||||
# Manage Key Pairs
|
||||
|
||||
<div className="head">Create Key Pair</div>
|
||||
<div className="text">Create at least one key pair for each project.</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.<br/><br/><img src={key02} alt="Key-Pair" /><br/><br/></li><li>Navigate to <span className="blue">Project</span> > <span className="blue"> Compute</span> > <span className="blue"> Key Pairs.</span><br/><br/><img src={key01} alt="Key-Pair" /><br/></li><br/><li>Click on <span className="blue">Create Key Pair.</span><br/><br/><img src={key03} alt="Key-Pair" /><br/><br/></li><li> In the Create Key Pair dialog box, enter a name for your key pair and type, and click <span className="blue">Create Key Pair</span><br/><br/><img src={key04} alt="Key-Pair" /><br/><br/></li></ol></div>
|
||||
|
||||
<div className="head">Import Key Pair</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left<br/><br/><img src={key02} alt="Key-Pair" /><br/><br/></li><li>Navigate to <span className="blue">Project</span> > <span className="blue"> Compute</span> > <span className="blue"> Key Pairs.</span><br/><br/><img src={key01} alt="Key-Pair" /><br/></li><br/><li>Click on <span className="blue">Import Public Key.</span><br/><br/><img src={key05} alt="Key-Pair" /><br/><br/></li><li>. In the Import Public Key dialog box, enter a name for your key pair, type and public key, and click <span className="blue">Import Public Key</span><br/><br/><img src={key06} alt="Key-Pair" /></li></ol></div>
|
||||
142
docs/CloudtopiaaInstances/Manage Load Balancers.md
Normal file
@ -0,0 +1,142 @@
|
||||
---
|
||||
sidebar_label: " Manage Load Balancers"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import bal01 from '@site/static/img/in15.png';
|
||||
import bal02 from '@site/static/img/bal01.png';
|
||||
import bal03 from '@site/static/img/bal02.png';
|
||||
import bal04 from '@site/static/img/bal03.png';
|
||||
import bal05 from '@site/static/img/bal04.png';
|
||||
import bal06 from '@site/static/img/bal05.png';
|
||||
|
||||
|
||||
|
||||
|
||||
# Manage Load Balancers
|
||||
|
||||
<div className="head">Create Load Balancer</div>
|
||||
<div className="text"><ol><li> Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left</li></ol></div>
|
||||
|
||||
<img src={bal01} alt="Load Balancer " /><br/><br/>
|
||||
|
||||
<div className="text">3. Navigate to <span className="blue">Project</span> > <span className="blue">Network</span> > <span className="blue">Load Balancers</span> </div><br/>
|
||||
|
||||
<img src={bal02} alt="Load Balancer " /><br/><br/>
|
||||
|
||||
<div className="text">4. Click on <span className="blue"> Create Load Balancer</span> add following details in <span className="blue"> Load Balancer Details </span> tab, and click <span className="blue"> Next.</span></div><br/>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Load Balancer Name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Subnet</td>
|
||||
<td>Select exiting private subnet</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
|
||||
<img src={bal03} alt="Load Balancer " /><br/><br/>
|
||||
|
||||
<div className="text">5. Add following details in <span className="blue">Listener Details</span> tab and click <span className="blue"> Next.</span></div><br/>
|
||||
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Listener name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Protocol </td>
|
||||
<td>Listener protocol</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Port</td>
|
||||
<td>If custom port is specified in Protocol field then we need to specify the listening port</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
|
||||
<img src={bal04} alt="Load Balancer " /><br/><br/>
|
||||
|
||||
<div className="text">6. Add following details in <span className="blue"> Pool Details </span> tab and click <span className="blue">Next. </span> </div><br/>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Pool name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Algorithm</td>
|
||||
<td>Load balancing algorithm. Available algorithms are<span className="blue"> ROUND_ROBIN, LEAST_CONNECTIONS</span> and <span className="blue"> SOURCE_IP.</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
|
||||
<img src={bal05} alt="Load Balancer " /><br/><br/>
|
||||
|
||||
<div className="div">7. Select servers from the list below and add in the pool. Mention port for each member in Pool Members
|
||||
tab and click <span className="blue">Next.</span></div> <br/>
|
||||
|
||||
<img src={bal06} alt="Load Balancer " /><br/><br/>
|
||||
|
||||
<div className="text">8. Add following details in <span className="blue"> Monitor Details</span> tab and click <span className="blue">Create Load Balancer</span></div><br/>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Listener name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Type</td>
|
||||
<td>Monitor type</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
|
||||
|
||||
|
||||
<!-- <image need to add> -->
|
||||
|
||||
<div className="text">9. Load Balancer wil take couple of minutes to provision and transition from Pending Create to Active
|
||||
state.</div>
|
||||
|
||||
|
||||
|
||||
<!-- <image need to add> -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <image need to add> -->
|
||||
|
||||
|
||||
|
||||
<div className="text">10. If load balancer needs to be accessed over internet, then we need assign floating ip. Open the
|
||||
dropdown of the loadbalancer and click on Associate Floating IP.</div>
|
||||
|
||||
<!-- <image need to add> -->
|
||||
|
||||
<div className="text">11. Select the floating IP already reserved to the project. If none are available select public IP subnet, it will
|
||||
automatically allocate a floating IP</div>
|
||||
|
||||
|
||||
|
||||
<!-- <image need to add> -->
|
||||
|
||||
<div className="text">12. Click on the dropdown beside load balancer name to view the details. We can find the Public IP
|
||||
assigned to the load balancer in the details.</div>
|
||||
|
||||
|
||||
<!-- <image need to add> -->
|
||||
|
||||
<div className="text">13.Following is a script to check if LB is functioning properly</div>
|
||||
198
docs/CloudtopiaaInstances/Manage Network.md
Normal file
@ -0,0 +1,198 @@
|
||||
---
|
||||
sidebar_label: "Manage Network"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import network05 from '@site/static/img/network05.png';
|
||||
import network07 from '@site/static/img/network07.png';
|
||||
import network03 from '@site/static/img/network03.png';
|
||||
import network04 from '@site/static/img/network04.png';
|
||||
import network06 from '@site/static/img/network06.png';
|
||||
import router01 from '@site/static/img/router01.png';
|
||||
import router02 from '@site/static/img/router02.png';
|
||||
import router03 from '@site/static/img/router03.png';
|
||||
import router04 from '@site/static/img/router04.png';
|
||||
import router05 from '@site/static/img/router05.png';
|
||||
import router06 from '@site/static/img/router06.png';
|
||||
import router07 from '@site/static/img/router07.png';
|
||||
import sg01 from '@site/static/img/S-G01.png';
|
||||
import sg02 from '@site/static/img/s-g02.png';
|
||||
import sgr from '@site/static/img/sgr.png';
|
||||
import sgr01 from '@site/static/img/sgr01.png';
|
||||
import rule01 from '@site/static/img/rule01.png';
|
||||
import rule02 from '@site/static/img/rule02.png';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Manage Network
|
||||
|
||||
<div className="head">Create Network</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left<br/><br/><img src={network05} alt="network" /><br/><br/></li><li> Navigate to <span className="blue">Project</span> > <span className="blue">Networks</span> > Click on <span className="blue">Create Network</span></li><br/><li>Specify Network Name in <span className="blue">Network tab</span> and click <span className="blue">Next</span>.<br/><br/><img src={network07} alt="network" /><br/><br/></li></ol></div>
|
||||
|
||||
<div className="text">5. Specify following details in <span className="blue">Subnet</span> tab and click <span className="blue">Next</span>.</div>
|
||||
<br/>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Subnet Name</td>
|
||||
<td>Subnet Name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Network Address </td>
|
||||
<td>Network address in CIDR format (e.g 192.168.1.0/24)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IP Version</td>
|
||||
<td>IP version (IPV4 or IPV6)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Gateway IP</td>
|
||||
<td>Subnet Gateway. Default is first IP of subnet.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
|
||||
|
||||
<img src={network03} alt="network" /><br/><br/>
|
||||
|
||||
<div className="text">6. Specify following details in <span className="blue">Subnet Details</span> tab and click <span className="blue">Create</span></div><br/>
|
||||
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Allocation Pool </td>
|
||||
<td>IP Address Allocation Pool. Each entry is start_ip,end_ip. (e.g
|
||||
192.168.1.10,192.168.1.200)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Network Address</td>
|
||||
<td>Network address in CIDR format (e.g 192.168.1.0/24)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DNS Servers </td>
|
||||
<td>IP address list of DNS name servers. One entry per line.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
|
||||
<img src={network04} alt="network" /><br/><br/>
|
||||
|
||||
<img src={network06} alt="network" /><br/><br/>
|
||||
|
||||
|
||||
<div className="head">Create Router</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.<br/><br/><img src={router01} alt="router" /><br/><br/></li></ol></div>
|
||||
|
||||
<div className="text">3. Navigate to <span className="blue">Project</span> > <span className="blue">Network</span> > <span className="blue">Routers</span> and click on <span className="blue">Create Router</span>.</div><br/>
|
||||
|
||||
<img src={router02} alt="router" /><br/><br/>
|
||||
|
||||
<div className="text">4. Specify network name and select public network for SNAT, and click <span className="blue">Create Router</span></div><br/>
|
||||
|
||||
|
||||
<img src={router03} alt="router" /><br/><br/>
|
||||
|
||||
<div className="head">Add Subnet to Router</div>
|
||||
|
||||
<div className="text">1. To connect a private network to the router, Navigate to "Project > Network > Routers".</div><br/>
|
||||
|
||||
<img src={router03} alt="router" /><br/><br/>
|
||||
|
||||
<div className="text">2. Click on the router name.</div><br/>
|
||||
|
||||
<img src={router04} alt="router" /><br/><br/>
|
||||
|
||||
<div className="text">3. Select <span className="blue">Interfaces</span>tab.</div><br/>
|
||||
<img src={router05} alt="router" /><br/><br/>
|
||||
|
||||
|
||||
<div className="text">4. Click on <span className="blue">Add Interface</span> and select private network to connect to the router, and click <span className="blue">Submit</span>.</div><br/>
|
||||
|
||||
<img src={router06} alt="router" /><br/><br/>
|
||||
|
||||
<img src={router07} alt="router" /><br/><br/>
|
||||
|
||||
|
||||
<div className="head">Create Security Group</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>. Select the appropriate project from the drop down menu at the top left</li></ol></div><br/>
|
||||
|
||||
|
||||
<img src={sg01} alt="Security Gropus" /><br/><br/>
|
||||
|
||||
<div className="text">Navigate to <span className="blue">Project</span> > <span className="blue">Network</span> > <span className="blue">Security Groups</span> and click on <span className="blue">Create Security Group.</span> </div><br/>
|
||||
|
||||
<div className="text">Specify security group name and click <span className="blue">Create Security Group.</span></div><br/>
|
||||
|
||||
<img src={sg02} alt="Security Gropus" /><br/><br/>
|
||||
|
||||
|
||||
<div className="head">Add Security Group Rule</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li></ol></div>
|
||||
|
||||
<img src={sgr} alt="Security Gropus Rule" /><br/><br/>
|
||||
|
||||
<div className="text">3. Navigate to <span className="blue">Project</span> > <span className="blue">Network</span> > <span className="blue">Security Groups.</span> </div><br/>
|
||||
|
||||
<img src={sgr01} alt="Security Gropus Rule" /><br/><br/>
|
||||
|
||||
<div className="text">4. click on <span className="blue">Manage Rules</span> of the security group in which you want to add rules</div><br/>
|
||||
|
||||
<img src={sgr01} alt="Security Gropus Rule" /><br/><br/>
|
||||
|
||||
|
||||
<div className="text">5. Click on <span className="blue">Add Rule</span> and add following details.</div>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Rule</td>
|
||||
<td>Select predefined rules or custom ones. In case of predefined rules, the rest of
|
||||
the fields will pre-populate.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Remote</td>
|
||||
<td>To specify an allowed IP range, select "CIDR". To allow access from all members
|
||||
of another security group select "Security Group".</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CIDR</td>
|
||||
<td>Remote CIDR where traffic is allowed if CIDR is selected for <span className="blue">Remote.</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Security Group</td>
|
||||
<td>Security Group name if <span className="blue">Security Group</span> is selected for <span className="blue">Remote.</span></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table><br/><br/>
|
||||
|
||||
<img src={rule01} alt="Security Gropus Rule" /><br/><br/>
|
||||
|
||||
<div className="text">6. Click on <span className="blue">Add</span> to create new rule</div><br/>
|
||||
|
||||
<img src={rule02} alt="Security Gropus Rule" /><br/><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
61
docs/CloudtopiaaInstances/Preface.md
Normal file
@ -0,0 +1,61 @@
|
||||
---
|
||||
sidebar_label: 'Preface'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
|
||||
# Preface
|
||||
|
||||
|
||||
<div className="head">Document Conventions</div><br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Admonitions and Call-Outs</div>
|
||||
|
||||
|
||||
|
||||
- ℹ️ **Info**: Additional detail about a topic will be called out with the "info" symbol.
|
||||
|
||||
- 💡 **Tip**: Tips and advice will appear with a "lightbulb" admonition.
|
||||
|
||||
- ⚠️ **Warning**: Warnings and strong recommendations will appear next to a caution exclamation.
|
||||
|
||||
- ❗ **Crucial**: Crucial advice and information will appear next to a red exclamation.<br/>
|
||||
|
||||
|
||||
<div className="head">Single-line Commands and Code</div>
|
||||
<div className="text">If instructed to type a single command, it will be displayed in a monospace font and highlighted like this
|
||||
example:</div>
|
||||
|
||||
<CodeBlock code={`ipa -vvv cert-find --all
|
||||
`} /><br/>
|
||||
|
||||
|
||||
<div className="head"> Multi-line Commands, Code / File Contents</div>
|
||||
<div className="text">If instructed to type multi-line commands, create or modify code blocks and or file contents the
|
||||
information will be monospaced and placed in a callout box like this example:</div>
|
||||
|
||||
<CodeBlock code={`require 'sinatra'
|
||||
get '/hi' do
|
||||
"Hello World!"
|
||||
end`} /><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
50
docs/intro.md
Normal file
@ -0,0 +1,50 @@
|
||||
<!-- ---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Tutorial Intro
|
||||
|
||||
Let's discover **Docusaurus in less than 5 minutes**.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Get started by **creating a new site**.
|
||||
|
||||
Or **try Docusaurus immediately** with **[docusaurus.new](https://docusaurus.new)**.
|
||||
|
||||
### What you'll need
|
||||
|
||||
- [Node.js](https://nodejs.org/en/download/) version 18.0 or above:
|
||||
- When installing Node.js, you are recommended to check all checkboxes related to dependencies.
|
||||
|
||||
## Generate a new site
|
||||
|
||||
Generate a new Docusaurus site using the **classic template**.
|
||||
|
||||
The classic template will automatically be added to your project after you run the command:
|
||||
|
||||
```bash
|
||||
npm init docusaurus@latest my-website classic
|
||||
```
|
||||
|
||||
You can type this command into Command Prompt, Powershell, Terminal, or any other integrated terminal of your code editor.
|
||||
|
||||
The command also installs all necessary dependencies you need to run Docusaurus.
|
||||
|
||||
## Start your site
|
||||
|
||||
Run the development server:
|
||||
|
||||
```bash
|
||||
cd my-website
|
||||
npm run start
|
||||
```
|
||||
|
||||
The `cd` command changes the directory you're working with. In order to work with your newly created Docusaurus site, you'll need to navigate the terminal there.
|
||||
|
||||
The `npm run start` command builds your website locally and serves it through a development server, ready for you to view at http://localhost:3000/.
|
||||
|
||||
Open `docs/intro.md` (this page) and edit some lines: the site **reloads automatically** and displays your changes. -->
|
||||
|
||||
|
||||
This is my new text
|
||||
176
docs/old-instance/hello.md
Normal file
@ -0,0 +1,176 @@
|
||||
---
|
||||
sidebar_label: 'Launch an instance'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Launch and manage instances
|
||||
|
||||
<div className="text">Instances are virtual machines that run inside the cloud. You can launch an instance from the following sources:<br/><ul><li>Images uploaded to the Image service.</li><li>Images that you have copied to a persistent volume. </li><li>Images that you have copied to a persistent volume. </li><li>Instances snapshot that you took. </li></ul></div>
|
||||
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}> Launch an instance </span>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li>
|
||||
<li>Select the appropriate project from the drop down menu at the top left.</li>
|
||||
<li>On the <span style={{ color: 'blue' }}>Project tab</span> , open the <span style={{ color: 'blue' }}>Compute tab</span> and click <span style={{ color: 'blue' }}>Instances</span> category.</li>
|
||||
The dashboard shows the instances with its name, its private and floating IP addresses, size, status, task, power state, and so on.
|
||||
<li>Click <span style={{ color: 'blue' }}>Launch Instance</span>.</li><li>In the <span style={{ color: 'blue' }}>Launch Instance</span> dialog box, specify the following values:<br/><span className="text"style={{ color: 'blue' }}>Details tab.</span> </li></ol><br /></div>
|
||||
|
||||
|
||||
<div className="text" ><strong>Instance Name</strong><br/></div>
|
||||
<span className="text" style={{ marginLeft:'20px'}}>Assign a name to the virtual machine.</span>
|
||||
|
||||
<!-- <div style="background-color: lightblue; padding: 10px; border-radius: 5px; border: 1px solid blue;">
|
||||
<strong>Note:</strong> The name you assign here becomes the initial host name of the server. If the name is longer than 63 characters, the Compute service truncates it automatically to ensure dnsmasq works correctly. <br />
|
||||
|
||||
After the server is built, if you change the server name in the API or change the host name directly, the names are not updated in the dashboard. <br />
|
||||
|
||||
Server names are not guaranteed to be unique when created so you could have two instances with the same host name. <br />
|
||||
</div> -->
|
||||
|
||||
|
||||
<!-- <div style={{ backgroundColor: 'lightblue', padding: '10px', borderRadius: '5px', border: '1px solid blue' }}>
|
||||
<strong>Note:</strong> This is a highlighted section inside a blue box.
|
||||
</div> -->
|
||||
|
||||
<div className="note"><strong>Note:</strong>The name you assign here becomes the initial host name of the server. If the name is longer than 63 characters, the Compute service truncates it automatically to ensure dnsmasq works correctly. <br />After the server is built, if you change the server name in the API or change the host name directly, the names are not updated in the dashboard. <br />Server names are not guaranteed to be unique when created so you could have two instances with the same host name. <br /></div><br />
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="text" ><strong>Description</strong><br/></div>
|
||||
<span className="text" style={{ marginLeft:'20px'}}>You can assign a brief description of the virtual machine.</span><br/>
|
||||
|
||||
<div className="text" ><strong>Availability Zone</strong><br/></div>
|
||||
<span className="text" style={{ marginLeft:'20px', textAlign: 'left'}}>By default, this value is set to the availability zone given by the cloud provider (for example, us-west or apac-south). For some cases, it could be nova.</span><br/>
|
||||
|
||||
<div className="text" ><strong>Count</strong><br/></div>
|
||||
<span className="text" style={{ marginLeft:'20px'}}>To launch multiple instances, enter a value greater than 1. The default is 1.<br/><span style={{ color: 'blue' }}> Source tab</span></span><br/>
|
||||
|
||||
|
||||
<div className="text" ><strong>Instance Boot Source</strong><br/></div>
|
||||
<div className="text" style={{ marginLeft:'20px'}}>Your options are:</div><br/>
|
||||
<span className="text" style={{ marginLeft:'20px' }}><strong>Boot from image</strong><br/></span> <span className="text" style={{ marginLeft:'20px' }} >If you choose this option, a new field for <span style={{ color: 'blue' }}>Image Name</span> displays. You can select the image from the list.</span><br/><br/>
|
||||
|
||||
<span className="text" style={{ marginLeft:'20px' }}><strong>Boot from snapshot</strong><br/></span> <span className="text"style={{ marginLeft:'20px' }} >If you choose this option, a new field for <span style={{ color: 'blue' }}> Instance Snapshot</span> displays. You can select the snapshot from the list.</span><br/><br/>
|
||||
|
||||
<span className="text" style={{ marginLeft:'20px' }}><strong>Boot from volume</strong><br/></span> <span className="text"style={{ marginLeft:'20px' }} >If you choose this option, a new field for <span style={{ color: 'blue' }}> Volume </span> displays. You can select the volume from the list.</span><br/><br/>
|
||||
|
||||
<span className="text" style={{ marginLeft:'20px' }}><strong>Boot from image (creates a new volume)</strong><br/></span> <span className="text" style={{ marginLeft:'20px' , textAlign: 'left' }} >With this option, you can boot from an image and create a volume by entering the <span style={{ color: 'blue' }}>Device Size </span> and <span style={{ color: 'blue' }}> Device Name</span> for your volume. Click the <span className="text"style={{color: 'blue' }} > Delete Volume on Instance Delete </span>option to delete the volume on deleting the instance.</span><br/><br/>
|
||||
|
||||
|
||||
<span className="text" style={{ marginLeft:'20px' }}><strong>Boot from volume snapshot (creates a new volume)</strong><br/></span> <span className="text"style={{ marginLeft:'20px' , textAlign: 'left' }} >Using this option, you can boot from a volume snapshot and create a new volume by choosing <span className="text"style={{color: 'blue' }} > Volume Snapshot</span> from a list and adding a <span className="text"style={{color: 'blue' }} >Device Name</span> for your volume. Click the <span className="text"style={{color: 'blue' }} >Delete Volume on Instance Delete</span> option to delete the volume on deleting the instance.</span><br/><br/>
|
||||
|
||||
<span className="text"><strong>Image Name</strong><br/> This field changes based on your previous selection. If you have chosen to launch an instance using an image, the<span style={{ color: 'blue' }}> Image Name</span> field displays. Select the image name from the dropdown list.</span><br/><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span className="text"><strong>Instance Snapshot</strong><br/>
|
||||
This field changes based on your previous selection. If you have chosen to launch an instance using a snapshot, the <span style={{ color: 'blue' }}>Instance Snapshot</span>field displays. Select the snapshot name from the dropdown list.</span><br/><br/>
|
||||
|
||||
<span className="text"><strong>Volume</strong><br/>
|
||||
This field changes based on your previous selection. If you have chosen to launch an instance using a volume, the <span style={{ color: 'blue' }}>Volume </span> field displays. Select the volume name from the dropdown list. If you want to delete the volume on instance delete, check the <span style={{ color: 'blue' }}>Delete Volume on Instance Delete</span> option.</span><br/>
|
||||
|
||||
<span className="text" style={{ color: 'blue' }}>Flavor tab </span><br/><br/>
|
||||
|
||||
<span className="text"><strong>Flavor</strong><br/>
|
||||
Specify the size of the instance to launch.</span> <br/>
|
||||
|
||||
<div className="note"><strong>Note:</strong>The flavor is selected based on the size of the image selected for launching an instance. For example, while creating an image, if you have entered the value in the Minimum RAM (MB) field as 2048, then on selecting the image, the default flavor is m1.small.</div><br/>
|
||||
|
||||
<span className="text" style={{ color: 'blue' }}>Networks tab</span><br/><br/>
|
||||
|
||||
|
||||
<span className="text"><strong>Selected Networks</strong><br/>To add a network to the instance, click the + in the Available field.</span><br/>
|
||||
|
||||
<span className="text" style={{ color: 'blue' }}>Network Ports tab</span><br/><br/>
|
||||
|
||||
<span className="text"><strong>Ports</strong><br/>
|
||||
Activate the ports that you want to assign to the instance.</span><br/>
|
||||
|
||||
<span className="text" style={{ color: 'blue' }}>Security Groups tab</span><br/><br/>
|
||||
|
||||
<div className="text"><strong>Security Groups</strong><br/>
|
||||
• Activate the security groups that you want to assign to the instance.<br/>
|
||||
• Security groups are a kind of cloud firewall that define which incoming network traffic is forwarded to instances.<br/>
|
||||
• If you have not created any security groups, you can assign only the default security group to the instance.</div>
|
||||
|
||||
<div className="text"style={{ color: 'blue' }}> Key Pair tab</div><br/>
|
||||
|
||||
<div className="text"><strong>Key Pair</strong><br/>
|
||||
Specify a key pair.<br/>
|
||||
If the image uses a static root password or a static key set (neither is recommended), you do not need to provide a key pair to launch the instance.</div>
|
||||
|
||||
<div className="text"style={{ color: 'blue' }}>Configuration tab</div><br/>
|
||||
|
||||
<div className="text"><strong>Customization Script Source</strong><br/>
|
||||
Specify a customization script that runs after your instance launches.</div>
|
||||
|
||||
<div className="text"style={{ color: 'blue' }}>Metadata tab</div><br/>
|
||||
|
||||
<div className="text"><strong>vailable Metadata</strong><br/>
|
||||
Add Metadata items to your instance.</div>
|
||||
<div className="text">Click <span style={{ color: 'blue' }}>Launch Instance.</span><br/><br/>
|
||||
The instance starts on a compute node in the cloud.</div><br/>
|
||||
|
||||
<div className="note"><strong>Note:</strong>If you did not provide a key pair, security groups, or rules, users can access the instance only from inside the cloud through VNC. Even pinging the instance is not possible without an ICMP rule configured. </div><br/>
|
||||
|
||||
<div className="text">You can also launch an instance from the Images or Volumes category when you launch an instance from an image or a volume respectively.<br/><br/>
|
||||
When you launch an instance from an image, OpenStack creates a local copy of the image on the compute node where the instance starts.<br/><br/>
|
||||
For details on creating images, see Creating images manually in the OpenStack Virtual Machine Image Guide.</div><br/><br/>
|
||||
|
||||
<div className="text">When you launch an instance from a volume, note the following steps:<br/><br/>
|
||||
To select the volume from which to launch, launch an instance from an arbitrary image on the volume. The arbitrary image that you select does not boot. Instead, it is replaced by the image on the volume that you choose in the next steps.<br/><br/>To boot a Xen image from a volume, the image you launch in must be the same type, fully virtualized or paravirtualized, as the one on the volume.<br/><br/>Select the volume or volume snapshot from which to boot. Enter a device name. Enter vda for KVM images or xvda for Xen images.</div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: When running QEMU without support for the hardware virtualization, set cpu_mode="none" alongside virt_type=qemu in /etc/nova/nova-compute.conf to solve the following error:</div><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
libvirtError: unsupported configuration: CPU mode 'host-model'
|
||||
for ``x86_64`` qemu domain on ``x86_64`` host is not supported by hypervisor<br/>
|
||||
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Connect to your instance by using SSH</span><br/>
|
||||
<div className="text">To use SSH to connect to your instance, use the downloaded keypair file.</div>
|
||||
|
||||
<div className="note"><strong>Note</strong>
|
||||
The user name is ubuntu for the Ubuntu cloud images on TryStack.</div>
|
||||
|
||||
<div className="text"><ol><li>Copy the IP address for your instance.</li><li>Use the ssh command to make a secure connection to the instance. For example:</li></ol></div>
|
||||
|
||||
|
||||
<CodeBlock code={`ssh -i MyKey.pem ubuntu@10.0.0.2
|
||||
`} />
|
||||
|
||||
<div className="text" style={{ marginLeft:'10px'}}>3. At the prompt, type **yes**. <br/> It is also possible to SSH into an instance without an SSH keypair, if the administrator has enabled root password injection. For more information about root password injection, see<span className="text" style={{textDecoration:'underline', color:'blue'}}> Injecting the administrator password</span> in the OpenStack Administrator Guide.</div><br/>
|
||||
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Track usage for instances</span><br/>
|
||||
<div className="text">You can track usage for instances for each project. You can track costs per month by showing meters like number of vCPUs, disks, RAM, and uptime for all your instances.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li> <li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span style={{ color: 'blue' }}>Project tab </span>, open the <span style={{ color: 'blue' }}> Compute tab </span> and click<span style={{ color: 'blue' }}> Overview</span> category.</li><li>To query the instance usage for a month, select a month and click <span style={{ color: 'blue' }}>Submit</span>.</li><li>To download a summary, click<span style={{ color: 'blue' }}> Download CSV Summary</span>.</li></ol> </div>
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Create an instance snapshot</span><br/>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span style={{ color: 'blue' }}> Project tab</span>, open the <span style={{ color: 'blue' }}>Compute tab </span> and click the <span style={{ color: 'blue' }}>Instances </span> category.</li><li>Select the instance from which to create a snapshot.</li><li>In the actions column, click Create Snapshot.</li><li>In the <span style={{ color: 'blue' }}>Create Snapshot</span> dialog box, enter a name for the snapshot, and click <span style={{ color: 'blue' }}>Create Snapshot</span>. <br/>The <span style={{ color: 'blue' }}>Images</span> category shows the instance snapshot.</li></ol></div>
|
||||
|
||||
|
||||
<div className="text">To launch an instance from the snapshot, select the snapshot and click <span style={{ color: 'blue' }}>Launch </span>. Proceed with launching an instance.</div>
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Manage an instance</span><br/>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span style={{ color: 'blue' }}> Project tab</span>, open the <span style={{ color: 'blue' }}> Compute tab </span> and click <span style={{ color: 'blue' }}>Instances </span>category.</li><li>Select an instance.</li><li>In the menu list in the actions column, select the state.</li><br/>You can resize or rebuild an instance. You can also choose to view the instance console log, edit instance or the security groups. Depending on the current state of the instance, you can pause, resume, suspend, soft or hard reboot, or terminate it.</ol></div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
63
docs/old-instance/tutorial-2.md
Normal file
@ -0,0 +1,63 @@
|
||||
---
|
||||
sidebar_label: 'Create an networks'
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Create and manage networks
|
||||
|
||||
<div className="text">The OpenStack Networking service provides a scalable system for managing the network connectivity within an OpenStack cloud deployment. It can easily and quickly react to changing network needs (for example, creating and assigning new IP addresses).<br/><br/>Networking in OpenStack is complex. This section provides the basic instructions for creating a network and a router. For detailed information about managing networks, refer to the <span style={{textDecoration:'underline', color:'blue'}}>OpenStack Networking Guide.</span></div> <br/>
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Create a network</span><br/>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li> <li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span style={{ color: 'blue' }}>Project tab </span>, open the <span style={{ color: 'blue' }}> Network tab </span> and click<span style={{ color: 'blue' }}> Network</span> category.</li><li>Click <span style={{ color: 'blue' }}>Create Network.</span>.</li><li>In the <span style={{ color: 'blue' }}> Create Network </span> dialog box, specify the following values.</li></ol> </div>
|
||||
|
||||
<div className="text" style={{ color: 'blue' , marginLeft:'30px'}}> Network tab</div>
|
||||
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px', }}>Network Name</span>: Specify a name to identify the network.</div>
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px'}}>Shared</span>: Share the network with other projects. Non admin users are not allowed to set shared option.</div>
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px'}}>Admin State</span>: The state to start the network in.</div>
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px'}}>Create Subnet</span>: Select this check box to create a subnet</div>
|
||||
<div className="text"><span style={{ marginLeft:'30px'}}>You do not have to specify a subnet when you create a network, but if you do not specify a subnet, the network can not be attached to an instance.</span></div>
|
||||
|
||||
<div className="text" style={{ color: 'blue' , marginLeft:'30px'}}>Subnet tab</div>
|
||||
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px', }}>Subnet Name</span>: Specify a name for the subnet.</div>
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px', }}>Network Address</span>: Specify the IP address for the subnet.</div>
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px', }}>IP Version</span>: Select IPv4 or IPv6.</div>
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px', }}>Gateway IP</span>: Specify an IP address for a specific gateway. This parameter is optional.</div>
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px', }}>Disable Gateway</span>: Select this check box to disable a gateway IP address.</div>
|
||||
|
||||
<div className="text"><span style={{ color: 'blue' , marginLeft:'30px', }}>Subnet Details tab</span> </div>
|
||||
<div className="text"><span className="blue"style={{ marginLeft:'30px', }}>Enable DHCP</span>: Select this check box to enable DHCP. </div>
|
||||
<div className="text"><span className="blue"style={{ marginLeft:'30px', }}>Allocation Pools</span>: Specify IP address pools.</div>
|
||||
<div className="text"><span className="blue"style={{ marginLeft:'30px', }}>DNS Name Servers</span>: Specify a name for the DNS server.</div>
|
||||
<div className="text"><span className="blue"style={{ marginLeft:'30px', }}>Host Routes</span>: Specify the IP address of host routes.</div>
|
||||
<div className="text"><span style={{ marginLeft:'30px', }}>6.Click </span><span className="blue">Create</span>.<br/>
|
||||
The dashboard shows the network on the <span className="blue">Networks tab</span>.</div><br/>
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Create a router</span><br/>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li> <li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Network tab</span> and click <span className="blue">Routers</span> category.</li><li>Click <span className="blue">Create Router</span>.</li><li>In the <span className="blue"> Create Router</span> dialog box, specify a name for the router and <span className="blue">External Network</span>, and click <span className="blue"> Create Router</span>.<br/>
|
||||
The new router is now displayed in the <span className="blue">Routers tab</span>.</li><li>Routers tab.
|
||||
To connect a private network to the newly created router, perform the following steps:<br/>
|
||||
a. On the <span className="blue">Routers tab</span>, click the name of the router.<br/>
|
||||
b. On the <span className="blue">Router Details</span> page, click the <span className="blue">Interfaces tab</span>, then click <span className="blue"> Add Interface</span>.<br/>
|
||||
c. In the <span className="blue"> Add Interface</span> dialog box, select a <span className="blue">Subnet</span>.</li>
|
||||
<span style={{ marginLeft:'20px', }}>• Optionally, in the <span className="blue"> Add Interface</span> dialog box, set an <span className="blue"> IP Address </span> for the router interface for the selected subnet.</span><br/>
|
||||
<span style={{ marginLeft:'20px', }}>• If you choose not to set the <span className="blue">IP Address</span> value, then by default OpenStack Networking uses the first host IP address in the subnet.</span><br/>
|
||||
<span style={{ marginLeft:'20px', }}>• The <span className="blue"> Router Name </span> and <span className="blue"> Router ID</span> fields are automatically updated.</span><li>Click <span className="blue">Add Interface</span>.</li>You have successfully created the router. You can view the new topology from the Network Topology tab.</ol></div>
|
||||
|
||||
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Create a port</span><br/>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li> <li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span className="blue">Project tab</span>, click <span className="blue"> Networks </span> category.</li><li>Click on the <span className="blue"> Network Name </span> of the network in which the port has to be created</li><li>Go to the <span className="blue">Ports tab</span> and click <span className="blue">Create Port</span>.</li><li>In the <span className="blue">Create Port </span> dialog box, specify the following values.</li><span className="blue">Name</span>: Specify name to identify the port.<br/><span className="blue">Device ID</span>: Device ID attached to the port.<br/><span className="blue">Device Owner</span>: Device owner attached to the port.<br/><span className="blue">Binding Host</span>: The ID of the host where the port is allocated<br/><span className="blue">Binding VNIC Type</span>: Select the VNIC type that is bound to the neutron port.<br/><li>Click <span className="blue">Create Port</span>.</li>The new port is now displayed in the <span className="blue">Ports </span>list.</ol> </div>
|
||||
|
||||
|
||||
|
||||
56
docs/old-instance/tutorial-3.md
Normal file
@ -0,0 +1,56 @@
|
||||
---
|
||||
sidebar_label: 'Create an object containers'
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Create and manage object containers
|
||||
|
||||
<div className="text">OpenStack Object Storage (swift) is used for redundant, scalable data storage using clusters of standardized servers to store petabytes of accessible data. It is a long-term storage system for large amounts of static data which can be retrieved and updated.<br/><br/>
|
||||
OpenStack Object Storage provides a distributed, API-accessible storage platform that can be integrated directly into an application or used to store any type of file, including VM images, backups, archives, or media files. In the OpenStack dashboard, you can only manage containers and objects.<br/><br/>
|
||||
In OpenStack Object Storage, containers provide storage for objects in a manner similar to a Windows folder or Linux file directory, though they cannot be nested. An object in OpenStack consists of the file to be stored in the container and any accompanying metadata.</div><br/>
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Create a container</span><br/>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li> <li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Click <span className="blue">Container</span>.</li><li>In the <span className="blue">Create Container </span> dialog box, enter a name for the container, and then click <span className="blue">Create</span>.</li>You have successfully created a container.</ol> </div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: To delete a container, click the More button and select Delete Container.</div><br/>
|
||||
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Upload an object</span><br/>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li> <li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Select the container in which you want to store your object.</li><li>Click the <span className="blue">Upload File</span> icon</li>The <span className="blue">Upload File To Container: <name></span> dialog box appears. <name> is the name of the container to which you are uploading the object.<li>Enter a name for the object.</li><li>Browse to and select the file that you want to upload.</li><li>Click <span className="blue">Upload File</span></li>You have successfully uploaded an object to the container.</ol></div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: To delete an object, click the More button and select Delete Object.</div> <br/>
|
||||
<span style={{fontSize: '34px', fontFamily:'open sans'}}>Manage an object</span><br/>
|
||||
<span className="text"><strong>To edit an object</strong></span>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li> <li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Select the container in which you want to store your object.</li><li>Click the menu button and choose <span className="blue">Edit</span> from the dropdown list.<br/>The <span className="blue">Edit Object</span> dialog box is displayed.</li><li>Browse to and select the file that you want to upload.</li><li>Click <span className="blue">Update Object</span>.</li></ol></div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: To delete an object, click the menu button and select Delete Object.</div><br/>
|
||||
|
||||
<span className="text"><strong>To copy an object from one container to another</strong></span>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li> <li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Select the container in which you want to store your object.</li><li>Click the menu button and choose <span className="blue">Copy</span> from the dropdown list.</li><li>In the <span className="blue">Copy Object</span> launch dialog box, enter the following values:<br/>
|
||||
• <span className="blue">Destination Container</span>: Choose the destination container from the list.<br/>
|
||||
• <span className="blue">Path</span>: Specify a path in which the new copy should be stored inside of the selected container.<br/>
|
||||
• <span className="blue">Destination object name</span>: Enter a name for the object in the new container.</li><li>Click <span className="blue">Copy Object</span>.</li></ol></div><br/>
|
||||
|
||||
<span className="text"><strong>To create a metadata-only object without a file</strong></span>
|
||||
|
||||
<div className="text">You can create a new object in container without a file available and can upload the file later when it is ready. This temporary object acts a place-holder for a new object, and enables the user to share object metadata and URL info in advance.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue"> Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Select the container in which you want to store your object.</li><li>Click <span className="blue"> Upload Object</span>.<br/>The <span className="blue">Upload Object To Container:</span> <name> dialog box is displayed.<br/><name> is the name of the container to which you are uploading the object.</li><li>Enter a name for the object.</li><li>Click <span className="blue">Update Object</span>.</li></ol></div><br/>
|
||||
|
||||
|
||||
<span className="text"><strong>To create a pseudo-folder</strong></span>
|
||||
<div className="text">Pseudo-folders are similar to folders in your desktop operating system. They are virtual collections defined by a common prefix on the object’s name.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the Project tab, open the Object Store tab and click Containers category.</li><li>Select the container in which you want to store your object.</li><li>Click Create Pseudo-folder <br/>The Create Pseudo-Folder in Container <name> dialog box is displayed. <name> is the name of the container to which you are uploading the object.</li></ol></div>
|
||||
|
||||
|
||||
48
docs/old-instance/tutorial-4.md
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
sidebar_label: 'Create an volumes'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Create and manage volumes
|
||||
|
||||
<div className="text">Volumes are block storage devices that you attach to instances to enable persistent storage. You can attach a volume to a running instance or detach a volume and attach it to another instance at any time. You can also create a snapshot from or delete a volume. Only administrative users can create volume types.</div><br/>
|
||||
|
||||
<span className="head">Create a volume</span>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue"> Volumes tab</span> and click <span className="blue">Volumes </span> category.</li><li>Click <span className="blue">Create Volume</span>.<br/>In the dialog box that opens, enter or select the following values.<br/><span className="blue">Volume Name</span>: Specify a name for the volume.<br/><span className="blue">Description</span>: Optionally, provide a brief description for the volume.<br/><span className="blue"> Volume Source</span>: Select one of the following options:<br/><br/>
|
||||
<span style={{ marginLeft:'20px', marginTop:'20px'}}>• No source, empty volume: Creates an empty volume. An empty volume does not contain a file system or a partition table.<br/></span>
|
||||
<span style={{ marginLeft:'20px', marginTop:'20px'}}>• Snapshot: If you choose this option, a new field for<span className="blue"> Use snapshot as a source</span> displays. You can select the snapshot from the list.<br/></span>
|
||||
<span style={{ marginLeft:'20px', marginTop:'20px'}}>• Image: If you choose this option, a new field for <span className="blue"> Use image as a source</span> displays. You can select the image from the list.<br/></span>
|
||||
<span style={{ marginLeft:'20px', marginTop:'20px'}}>• Volume: If you choose this option, a new field for <span className="blue">Use volume as a source</span> displays. You can select the volume from the list. Options to use a snapshot or a volume as the source for a volume are displayed only if there are existing snapshots or volumes.<br/> <br/></span> <span className="blue">Type</span>: Leave this field blank.<br/><span className="blue">Size (GB)</span>: The size of the volume in gibibytes (GiB).<br/><span className="blue">Availability Zone</span>: Select the Availability Zone from the list. By default, this value is set to the availability zone given by the cloud provider (for example, ***us-west or apac-south***). For some cases, it could be nova.</li><li>Click <span className="blue">Create Volume</span>.</li>The dashboard shows the volume on the <span className="blue">Volumes tab</span>.</ol></div>
|
||||
|
||||
<span className="head">Attach a volume to an instance</span>
|
||||
|
||||
<div className="text">After you create one or more volumes, you can attach them to instances. You can attach a volume to one instance at a time.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Volumes tab</span> and click <span className="blue"> Volumes </span>category.</li><li>Select the volume to add to an instance and click <span className="blue">Manage Attachments</span>.</li><li>In the <span className="blue">Manage Volume Attachments</span> dialog box, select an instance.</li><li>Enter the name of the device from which the volume is accessible by the instance.</li><br/><span className="note"><strong>Note</strong>: The actual device name might differ from the volume name because of hypervisor settings.</span><br/> <br/><li>Click <span className="blue">Attach Volume</span> <br/>The dashboard shows the instance to which the volume is now attached and the device name.<br/>
|
||||
You can view the status of a volume in the Volumes tab of the dashboard. The volume is either Available or In-Use.<br/>
|
||||
Now you can log in to the instance and mount, format, and use the disk.</li></ol></div>
|
||||
|
||||
<span className="head">Detach a volume from an instance</span>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Volumes tab</span> and click the <span className="blue">Volumes </span>category.</li><li>Select the volume and click <span className="blue">Manage Attachments</span>.</li><li>Click <span className="blue">Detach Volume</span> and confirm your changes.<br/>A message indicates whether the action was successful.</li></ol></div>
|
||||
|
||||
<span className="head">Create a snapshot from a volume</span>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Volumes tab</span> and click <span className="blue">Volumes</span> category.</li><li>Select a volume from which to create a snapshot.</li><li>In the<span className="blue"> Actions</span> column, click <span className="blue"> Create Snapshot</span>.</li><li>In the dialog box that opens, enter a snapshot name and a brief description.</li><li>Confirm your changes.<br/>The dashboard shows the new volume snapshot in Volume Snapshots tab.</li></ol></div>
|
||||
|
||||
|
||||
<span className="head">Edit a volume</span>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Volumes tab</span> and click <span className="blue">Volumes </span>category.</li><li>Select the volume that you want to edit.</li><li>In the <span className="blue">Actions</span> column, click <span className="blue">Edit Volume</span>.</li><li>In the <span className="blue">Edit Volume</span> dialog box, update the name and description of the volume.</li><li>Click <span className="blue">Edit Volume</span>.</li></ol></div>
|
||||
|
||||
<div className="note"><strong>Note</strong>:You can extend a volume by using the Extend Volume option available in the More dropdown list and entering the new value for volume size.</div><br/>
|
||||
|
||||
<span className="head">Delete a volume</span>
|
||||
<div className="text">When you delete an instance, the data in its attached volumes is not deleted.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboar</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project tab</span>, open the <span className="blue">Volumes tab</span> and click <span className="blue">Volumes</span>category.</li><li>Select the check boxes for the volumes that you want to delete.</li><li>Click<span className="blue"> Delete Volumes</span> and confirm your choice.<br/>A message indicates whether the action was successful.</li></ol></div>
|
||||
|
||||
|
||||
|
||||
60
docs/old-instance/tutorial-5.md
Normal file
@ -0,0 +1,60 @@
|
||||
---
|
||||
sidebar_label: 'Supported Browsers'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Supported Browsers
|
||||
|
||||
<div className="text">Horizon is primarily tested and supported on the latest version of Firefox and the latest version of Chrome. Issues related to IE, Safari and Opera will also be considered.<br/><br/>This page aims to informally document what that means for different releases, everyone is warmly encouraged to update this page based on the versions they’ve tested with.</div>
|
||||
|
||||
<div className="text"><strong>Legend:</strong><ul><li>Very good: Very well tested, should work as expected</li><li>Good: Moderately tested, should look nice and work fine, maybe a few visual hiccups</li><li>Poor: Doesn’t look good</li><li>Broken: Essential functionality not working (link to bug in the notes)</li><li>No: Not supported</li></ul></div><br/>
|
||||
|
||||
<table>
|
||||
<thead style={{ backgroundColor: 'blue', color: 'white' }}>
|
||||
<tr>
|
||||
<th>Browser</th>
|
||||
<th>Status</th>
|
||||
<th style={{ textAlign: 'center', }}>Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td>Very good</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Chrome</td>
|
||||
<td>Very good</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MS Edge</td>
|
||||
<td>Poor</td>
|
||||
<td>There’re some bugs but most of features work</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IE 11</td>
|
||||
<td>Poor</td>
|
||||
<td><strong>There’re some bugs but most</strong> of features work</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IE 10 and below</td>
|
||||
<td>Not supported.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Safari</td>
|
||||
<td>Good</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Opera</td>
|
||||
<td>?</td>
|
||||
<td>It should work good with Webkit</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
22
docs/old-instance/tutorial-6.md
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
sidebar_label: 'Administration Guide'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Administration Guide
|
||||
|
||||
<div className="text">The OpenStack Dashboard is a web-based interface that allows you to manage OpenStack resources and services. The Dashboard allows you to interact with the OpenStack Compute cloud controller using the OpenStack APIs. For more information about installing and configuring the Dashboard, see the <span style={{textDecoration:'underline', color: '#0000b3'}}>Installation Guide</span> for your operating system.</div>
|
||||
|
||||
<div className="text" style={{textDecoration:'underline', color: '#0000b3'}} ><ul><li>Customize and configure the Dashboard<br/>* Customize the Dashboard<br/>* Configure the Dashboard</li><br/>
|
||||
<li>Set up session storage for the Dashboard <br/>* Local memory cache <br/>* Cached database<br/>* Cookies</li><br/>
|
||||
<li>Create and manage images<br/>* Create images<br/>* Update images<br/>* Delete images</li><br/>
|
||||
<li>Create and manage roles<br/>* Create a role<br/>* Edit a role<br/>* Delete a role</li><br/><li>Manage projects and users <br/>* Add a new project<br/>* Delete a project<br/>* Update a project<br/>* Add a new user<br/>* Delete a new user <br/>* Update a user</li><br/>
|
||||
<li>Manage instances<br/>* Create instance snapshots<br/>* Control the state of an instance<br/>* Track usage</li><br/><li>Manage flavors<br/>* Create flavors<br/>* Update Metadata<br/>* Delete flavors</li><br/><li>Manage volumes and volume types<br/>* Create a volume type<br/>* Create an encrypted volume type<br/>* Delete volume types<br/>* Delete volumes</li><br/><li>View and manage quotas<br/>* View default project quotas<br/>* Update project quotas</li><br/><li>View services information</li><br/> <li>Create and manage host aggregates<br/>* To create a host aggregate<br/>* To manage host aggregates</li></ul></div><br/>
|
||||
|
||||
<div className="text"><ul><li>To deploy the dashboard, see the <span style={{textDecoration:'underline', color: '#0000b3'}} > Installation Guide.</span></li><li>To launch instances with the dashboard as an end user, see the <span style={{textDecoration:'underline', color: '#0000b3'}} >Launch and manage instances</span> in the OpenStack End User Guide.</li><li>To create and manage ports, see the <span style={{textDecoration:'underline', color: '#0000b3'}} >Create and manage networks</span> section of the OpenStack End User Guide.</li></ul></div>
|
||||
|
||||
|
||||
|
||||
349
docs/old-instance/tutorial-7.md
Normal file
@ -0,0 +1,349 @@
|
||||
---
|
||||
sidebar_label: 'Customize and configure the Dashboard'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Customize and configure the Dashboard
|
||||
|
||||
<div className="text">Once you have the Dashboard installed, you can customize the way it looks and feels to suit the needs of your environment, your project, or your business.<br/><br/>
|
||||
You can also configure the Dashboard for a secure HTTPS deployment, or an HTTP deployment. The standard OpenStack installation uses a non-encrypted HTTP channel, but you can enable SSL support for the Dashboard.<br/>
|
||||
For information on configuring HTTPS or HTTP, see Configure the Dashboard.</div>
|
||||
|
||||
<div className="head">Customize the Dashboard</div>
|
||||
<div className="text">The OpenStack Dashboard on Ubuntu installs the ***openstack-dashboard-ubuntu-theme*** package by default. If you do not want to use this theme, remove it and its dependencies:</div>
|
||||
|
||||
<CodeBlock code={`# apt-get remove --auto-remove openstack-dashboard-ubuntu-theme
|
||||
`} /> <br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: This guide focuses on the local_settings.py file.</div><br/>
|
||||
<div className="text">The following Dashboard content can be customized to suit your needs:</div>
|
||||
<div className="text"><ul><li>Logo</li><li>Site colors</li><li>HTML title</li><li>Logo link</li><li>Help URL</li></ul></div>
|
||||
|
||||
<div className="head">Logo and site colors</div>
|
||||
<div className="text"><ol><li>Create two PNG logo files with transparent backgrounds using the following sizes:<br/>• Login screen: 365 x 50<br/>• Logged in banner: 216 x 35</li><li>Upload your new images to ***/usr/share/openstack-dashboard/openstack_dashboard/static/dashboard/img/***.</li><li>Create a CSS style sheet in ***/usr/share/openstack-dashboard/openstack_dashboard/static/dashboard/scss/***.</li><li>Change the colors and image file names as appropriate. Ensure the relative directory paths are the same. The following example file shows you how to customize your CSS file:</li></ol></div>
|
||||
|
||||
<CodeBlock code={`/*
|
||||
* New theme colors for dashboard that override the defaults:
|
||||
* dark blue: #355796 / rgb(53, 87, 150)
|
||||
* light blue: #BAD3E1 / rgb(186, 211, 225)
|
||||
*
|
||||
* By Preston Lee <plee@tgen.org>
|
||||
*/
|
||||
h1.brand {
|
||||
background: #355796 repeat-x top left;
|
||||
border-bottom: 2px solid #BAD3E1;
|
||||
}
|
||||
h1.brand a {
|
||||
background: url(../img/my_cloud_logo_small.png) top left no-repeat;
|
||||
}
|
||||
#splash .login {
|
||||
background: #355796 url(../img/my_cloud_logo_medium.png) no-repeat center 35px;
|
||||
}
|
||||
#splash .login .modal-header {
|
||||
border-top: 1px solid #BAD3E1;
|
||||
}
|
||||
.btn-primary {
|
||||
background-image: none !important;
|
||||
background-color: #355796 !important;
|
||||
border: none !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
.btn-primary:hover,
|
||||
.btn-primary:active {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
background-color: #BAD3E1 !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">5. Open the following HTML template in an editor of your choice:</div>
|
||||
|
||||
<CodeBlock code={`/usr/share/openstack-dashboard/openstack_dashboard/templates/_stylesheets.html
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">6. Add a line to include your newly created style sheet. For example, ***custom.css*** file:</div>
|
||||
|
||||
<CodeBlock code={`<link href='{{ STATIC_URL }}bootstrap/css/bootstrap.min.css' media='screen' rel='stylesheet' />
|
||||
<link href='{{ STATIC_URL }}dashboard/css/{% choose_css %}' media='screen' rel='stylesheet' />
|
||||
<link href='{{ STATIC_URL }}dashboard/css/custom.css' media='screen' rel='stylesheet' />
|
||||
`} /> <br/>
|
||||
|
||||
|
||||
<div className="text">7. Restart the Apache service.</div>
|
||||
|
||||
<div className="text">8. To view your changes, reload your Dashboard. If necessary, go back and modify your CSS file as appropriate.</div>
|
||||
|
||||
<div className="head">HTML title</div>
|
||||
|
||||
<div className="text">1. Set the HTML title, which appears at the top of the browser window, by adding the following line to ***local_settings.py:***</div>
|
||||
|
||||
<CodeBlock code={`SITE_BRANDING = "Example, Inc. Cloud"
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">2. Restart Apache for this change to take effect.</div>
|
||||
|
||||
|
||||
<div className="head">Logo link</div>
|
||||
<div className="text">1. The logo also acts as a hyperlink. The default behavior is to redirect to ***horizon:user_home***. To change this, add the following attribute to ***local_settings.py:***</div>
|
||||
|
||||
<CodeBlock code={`SITE_BRANDING_LINK = "http://example.com"
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">2. Restart Apache for this change to take effect.</div>
|
||||
|
||||
|
||||
<div className="head">Help URL</div>
|
||||
<div className="text">1. By default, the help URL points to <span style={{textDecoration:'underline', color: '#0000b3'}} >https://docs.openstack.org.</span> To change this, edit the following attribute in ***local_settings.py:***</div>
|
||||
|
||||
<CodeBlock code={`HORIZON_CONFIG["help_url"] = "http://openstack.mycompany.org"
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">2. Restart Apache for this change to take effect.</div>
|
||||
|
||||
<div className="head">Configure the Dashboard</div>
|
||||
<div className="text">The following section on configuring the Dashboard for a secure HTTPS deployment, or a HTTP deployment, uses concrete examples to ensure the procedure is clear. The file path varies by distribution, however. If needed, you can also configure the VNC window size in the Dashboard.</div>
|
||||
<div className="text" style={{ fontSize:'28px' }}>Configure the Dashboard for HTTP</div>
|
||||
<div className="text">You can configure the Dashboard for a simple HTTP deployment. The standard installation uses a non-encrypted HTTP channel.</div>
|
||||
|
||||
<div className="text">1. Specify the host for your Identity service endpoint in the local_settings.py file with the OPENSTACK_HOST setting.<br/><br/>The following example shows this setting:</div>
|
||||
|
||||
<CodeBlock code={`import os
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
DEBUG = False
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
PROD = True
|
||||
|
||||
SITE_BRANDING = 'OpenStack Dashboard'
|
||||
|
||||
# Ubuntu-specific: Enables an extra panel in the 'Settings' section
|
||||
# that easily generates a Juju environments.yaml for download,
|
||||
# preconfigured with endpoints and credentials required for bootstrap
|
||||
# and service deployment.
|
||||
ENABLE_JUJU_PANEL = True
|
||||
|
||||
# Note: You should change this value
|
||||
SECRET_KEY = 'elj1IWiLoWHgryYxFT6j7cM5fGOOxWY0'
|
||||
|
||||
# Specify a regular expression to validate user passwords.
|
||||
# HORIZON_CONFIG = {
|
||||
# "password_validator": {
|
||||
# "regex": '.*',
|
||||
# "help_text": _("Your password does not meet the requirements.")
|
||||
# }
|
||||
# }
|
||||
|
||||
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND' : 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
'LOCATION' : '127.0.0.1:11211'
|
||||
}
|
||||
}
|
||||
|
||||
# Send email to the console by default
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
# Or send them to /dev/null
|
||||
#EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
|
||||
|
||||
# Configure these for your outgoing email host
|
||||
# EMAIL_HOST = 'smtp.my-company.com'
|
||||
# EMAIL_PORT = 25
|
||||
# EMAIL_HOST_USER = 'djangomail'
|
||||
# EMAIL_HOST_PASSWORD = 'top-secret!'
|
||||
|
||||
# For multiple regions uncomment this configuration, and add (endpoint, title).
|
||||
# AVAILABLE_REGIONS = [
|
||||
# ('http://cluster1.example.com/identity/v3', 'cluster1'),
|
||||
# ('http://cluster2.example.com/identity/v3', 'cluster2'),
|
||||
# ]
|
||||
|
||||
OPENSTACK_HOST = "127.0.0.1"
|
||||
OPENSTACK_KEYSTONE_URL = "http://%s/identity/v3" % OPENSTACK_HOST
|
||||
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
|
||||
|
||||
# The OPENSTACK_KEYSTONE_BACKEND settings can be used to identify the
|
||||
# capabilities of the auth backend for Keystone.
|
||||
# If Keystone has been configured to use LDAP as the auth backend then set
|
||||
# can_edit_user to False and name to 'ldap'.
|
||||
#
|
||||
# TODO(tres): Remove these once Keystone has an API to identify auth backend.
|
||||
OPENSTACK_KEYSTONE_BACKEND = {
|
||||
'name': 'native',
|
||||
'can_edit_user': True
|
||||
}
|
||||
|
||||
# OPENSTACK_ENDPOINT_TYPE specifies the endpoint type to use for the endpoints
|
||||
# in the Keystone service catalog. Use this setting when Horizon is running
|
||||
# external to the OpenStack environment. The default is 'internalURL'.
|
||||
#OPENSTACK_ENDPOINT_TYPE = "publicURL"
|
||||
|
||||
# The number of Swift containers and objects to display on a single page before
|
||||
# providing a paging element (a "more" link) to paginate results.
|
||||
API_RESULT_LIMIT = 1000
|
||||
|
||||
# If you have external monitoring links, eg:
|
||||
# EXTERNAL_MONITORING = [
|
||||
# ['Nagios','http://foo.com'],
|
||||
# ['Ganglia','http://bar.com'],
|
||||
# ]
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
# When set to True this will disable all logging except
|
||||
# for loggers specified in this configuration dictionary. Note that
|
||||
# if nothing is specified here and disable_existing_loggers is True,
|
||||
# django.db.backends will still log unless it is disabled explicitly.
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'null': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.NullHandler',
|
||||
},
|
||||
'console': {
|
||||
# Set the level to "DEBUG" for verbose output logging.
|
||||
'level': 'INFO',
|
||||
'class': 'logging.StreamHandler',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
# Logging from django.db.backends is VERY verbose, send to null
|
||||
# by default.
|
||||
'django.db.backends': {
|
||||
'handlers': ['null'],
|
||||
'propagate': False,
|
||||
},
|
||||
'horizon': {
|
||||
'handlers': ['console'],
|
||||
'propagate': False,
|
||||
},
|
||||
'novaclient': {
|
||||
'handlers': ['console'],
|
||||
'propagate': False,
|
||||
},
|
||||
'keystoneclient': {
|
||||
'handlers': ['console'],
|
||||
'propagate': False,
|
||||
}
|
||||
}
|
||||
}
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">The service catalog configuration in the Identity service determines whether a service appears in the Dashboard. For the full listing, see <span style={{textDecoration:'underline', color: '#0000b3'}}>Settings Reference.</span></div>
|
||||
<div className="text">2. Restart the Apache HTTP Server.</div>
|
||||
<div className="text">3. Restart ***memcached***.</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Configure the Dashboard for HTTPS</div>
|
||||
<div ClassName="text">You can configure the Dashboard for a secured HTTPS deployment. While the standard installation uses a non-encrypted HTTP channel, you can enable SSL support for the Dashboard.<br/>This example uses the ***http://openstack.example.com*** domain. Use a domain that fits your current setup.</div>
|
||||
|
||||
<div className="text">1. In the ***local_settings.py*** file, update the following options:</div>
|
||||
|
||||
<CodeBlock code={`CSRF_COOKIE_SECURE = True
|
||||
SESSION_COOKIE_SECURE = True
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
`} />
|
||||
|
||||
<div className="text">The other options require that HTTPS is enabled; these options defend against cross-site scripting.</div>
|
||||
|
||||
<div className="text">2. Edit the ***openstack-dashboard***.conf file as shown in the <strong>Example After:</strong></div>
|
||||
|
||||
<div className="text"><strong>Example Before</strong></div>
|
||||
|
||||
<CodeBlock code={`WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi.py
|
||||
WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10
|
||||
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
|
||||
<Location />
|
||||
<ifVersion >=2.4>
|
||||
Require all granted
|
||||
</ifVersion>
|
||||
<ifVersion <2.4>
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</ifVersion>
|
||||
</Location>
|
||||
`} />
|
||||
|
||||
<div className="text"><strong>Example After</strong></div>
|
||||
|
||||
<CodeBlock code={`<VirtualHost *:80>
|
||||
ServerName openstack.example.com
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond %{HTTPS} off
|
||||
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
|
||||
</IfModule>
|
||||
<IfModule !mod_rewrite.c>
|
||||
RedirectPermanent / https://openstack.example.com
|
||||
</IfModule>
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost *:443>
|
||||
ServerName openstack.example.com
|
||||
|
||||
SSLEngine On
|
||||
# Remember to replace certificates and keys with valid paths in your environment
|
||||
SSLCertificateFile /etc/apache2/SSL/openstack.example.com.crt
|
||||
SSLCACertificateFile /etc/apache2/SSL/openstack.example.com.crt
|
||||
SSLCertificateKeyFile /etc/apache2/SSL/openstack.example.com.key
|
||||
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
|
||||
|
||||
# HTTP Strict Transport Security (HSTS) enforces that all communications
|
||||
# with a server go over SSL. This mitigates the threat from attacks such
|
||||
# as SSL-Strip which replaces links on the wire, stripping away https prefixes
|
||||
# and potentially allowing an attacker to view confidential information on the
|
||||
# wire
|
||||
Header add Strict-Transport-Security "max-age=15768000"
|
||||
|
||||
WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi.py
|
||||
WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10
|
||||
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
|
||||
<Location />
|
||||
Options None
|
||||
AllowOverride None
|
||||
# For Apache http server 2.4 and later:
|
||||
<ifVersion >=2.4>
|
||||
Require all granted
|
||||
</ifVersion>
|
||||
# For Apache http server 2.2 and earlier:
|
||||
<ifVersion <2.4>
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</ifVersion>
|
||||
</Location>
|
||||
</VirtualHost>
|
||||
`} />
|
||||
|
||||
<div className="text">In this configuration, the Apache HTTP Server listens on port 443 and redirects all non-secure requests to the HTTPS protocol. The secured section defines the private key, public key, and certificate to use.</div>
|
||||
|
||||
<div className="text">3. Restart the Apache HTTP Server.</div>
|
||||
<div className="text">4. Restart ***memcached***.<br/>If you try to access the Dashboard through HTTP, the browser redirects you to the HTTPS page.</div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: Configuring the Dashboard for HTTPS also requires enabling SSL for the noVNC proxy service. On the controller node, add the following additional options to the ***[DEFAULT]*** section of the ***/etc/nova/nova.conf file:***</div><br/>
|
||||
|
||||
<CodeBlock code={`[DEFAULT]
|
||||
# ...
|
||||
ssl_only = true
|
||||
cert = /etc/apache2/SSL/openstack.example.com.crt
|
||||
key = /etc/apache2/SSL/openstack.example.com.key
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">On the compute nodes, ensure the ***nonvncproxy_base_url*** option points to a URL with an HTTPS scheme:</div>
|
||||
|
||||
<CodeBlock code={`[DEFAULT]
|
||||
# ...
|
||||
novncproxy_base_url = https://controller:6080/vnc_auto.html
|
||||
`} /> <br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
167
docs/old-instance/tutorial-8.md
Normal file
@ -0,0 +1,167 @@
|
||||
---
|
||||
sidebar_label: 'Set up session storage for the Dashboard'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Set up session storage for the Dashboard
|
||||
|
||||
<div className="text">The Dashboard uses <span style={{textDecoration:'underline', color: '#0000b3'}}>Django sessions framework</span> to handle user session data. However, you can use any available session back end. You customize the session back end through the **SESSION_ENGINE** setting in your ***local_settings.py*** file.</div>
|
||||
|
||||
<div className="text">After architecting and implementing the core OpenStack services and other required services, combined with the Dashboard service steps below, users and administrators can use the OpenStack dashboard. Refer to the <span style={{textDecoration:'underline', color: '#0000b3'}}>OpenStack User Documentation</span> chapter of the OpenStack End User Guide for further instructions on logging in to the Dashboard.</div>
|
||||
|
||||
<div className="text">The following sections describe the pros and cons of each option as it pertains to deploying the Dashboard.</div>
|
||||
|
||||
<div className="head">Local memory cache</div>
|
||||
<div className="text">Local memory storage is the quickest and easiest session back end to set up, as it has no external dependencies whatsoever. It has the following significant drawbacks: <ul><li>No shared storage across processes or workers.</li><li>No persistence after a process terminates.</li></ul></div>
|
||||
|
||||
<div className="text">The local memory back end is enabled as the default for Horizon solely because it has no dependencies. It is not recommended for production use, or even for serious development work.</div>
|
||||
|
||||
<CodeBlock code={`SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
|
||||
CACHES = {
|
||||
'default' : {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
|
||||
}
|
||||
}
|
||||
`} /> <br/>
|
||||
|
||||
|
||||
<div className="text">You can use applications such as ***Memcached*** or ***Redis*** for external caching. These applications offer persistence and shared storage and are useful for small-scale deployments and development.</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Memcached</div>
|
||||
|
||||
<div className="text">Memcached is a high-performance and distributed memory object caching system providing in-memory key-value store for small chunks of arbitrary data.<br/><br/>Requirements:</div>
|
||||
|
||||
<div className="text"><ul><li>Memcached service running and accessible.
|
||||
</li><li>Python module ***python-memcached*** installed.</li></ul></div>
|
||||
|
||||
<CodeBlock code={`SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
'LOCATION': 'my_memcached_host:11211',
|
||||
}
|
||||
}
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Redis</div>
|
||||
|
||||
<div className="text">Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server.<br/><br/>Requirements:</div>
|
||||
|
||||
<div className="text"><ul><li>Redis service running and accessible.
|
||||
</li><li>Python modules ***redis*** and ***django-redis*** installed.</li></ul></div>
|
||||
|
||||
<CodeBlock code={`SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "redis_cache.cache.RedisCache",
|
||||
"LOCATION": "127.0.0.1:6379:1",
|
||||
"OPTIONS": {
|
||||
"CLIENT_CLASS": "redis_cache.client.DefaultClient",
|
||||
}
|
||||
}
|
||||
}
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Initialize and configure the database</div>
|
||||
|
||||
<div className="text">Database-backed sessions are scalable, persistent, and can be made high-concurrency and highly available.<br/><br/>However, database-backed sessions are one of the slower session storages and incur a high overhead under heavy usage. Proper configuration of your database deployment can also be a substantial undertaking and is far beyond the scope of this documentation.</div>
|
||||
|
||||
<div className="text">1. Start the MySQL command-line client.</div>
|
||||
|
||||
<CodeBlock code={`# mysql
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">2. Enter the MySQL root user’s password when prompted.</div>
|
||||
|
||||
<div className="text">3. To configure the MySQL database, create the dash database.</div>
|
||||
|
||||
<CodeBlock code={`mysql> CREATE DATABASE dash;
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">4. Create a MySQL user for the newly created dash database that has full control of the database. Replace DASH_DBPASS with a password for the new user.</div>
|
||||
|
||||
<CodeBlock code={`mysql> GRANT ALL PRIVILEGES ON dash.* TO 'dash'@'%' IDENTIFIED BY 'DASH_DBPASS';
|
||||
mysql> GRANT ALL PRIVILEGES ON dash.* TO 'dash'@'localhost' IDENTIFIED BY 'DASH_DBPASS';
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">5. Enter quit at the mysql> prompt to exit MySQL.</div>
|
||||
<div className="text">6. In the ***local_settings.py*** file, change these options:</div>
|
||||
|
||||
<CodeBlock code={`SESSION_ENGINE = 'django.contrib.sessions.backends.db'
|
||||
DATABASES = {
|
||||
'default': {
|
||||
# Database configuration here
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'dash',
|
||||
'USER': 'dash',
|
||||
'PASSWORD': 'DASH_DBPASS',
|
||||
'HOST': 'localhost',
|
||||
'default-character-set': 'utf8'
|
||||
}
|
||||
}
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">7. After configuring the ***local_settings.py*** file as shown, you can run the ***manage.py migrate*** command to populate this newly created database.</div>
|
||||
|
||||
<CodeBlock code={`# /usr/share/openstack-dashboard/manage.py migrate
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">8. To avoid a warning when you restart Apache on Ubuntu, create a ***blackhole*** directory in the Dashboard directory, as follows.</div>
|
||||
|
||||
<CodeBlock code={`# mkdir -p /var/lib/dash/.blackhole
|
||||
`} /> <br/>
|
||||
|
||||
<div className="text">9. Restart the Apache service.</div>
|
||||
<div className="text">10. On Ubuntu, restart the nova-api service to ensure that the API server can connect to the Dashboard without error.</div>
|
||||
|
||||
<CodeBlock code={`# service nova-api restart
|
||||
`} /> <br/>
|
||||
|
||||
<div className="head">Cached database</div>
|
||||
|
||||
<div className="text">To mitigate the performance issues of database queries, you can use the Django cached_db session back end, which utilizes both your database and caching infrastructure to perform write-through caching and efficient retrieval.<br/> <br/>Enable this hybrid setting by configuring both your database and cache, as discussed previously. Then, set the following value:</div>
|
||||
|
||||
<CodeBlock code={`SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
|
||||
`} /> <br/>
|
||||
|
||||
<div className="head">Cookies</div>
|
||||
|
||||
<div className="text">If you use Django 1.4 or later, the signed_cookies back end avoids server load and scaling problems.</div>
|
||||
|
||||
<div className="text">This back end stores session data in a cookie, which is stored by the user’s browser. The back end uses a cryptographic signing technique to ensure session data is not tampered with during transport. This is not the same as encryption; session data is still readable by an attacker.</div>
|
||||
|
||||
<div className="text">The pros of this engine are that it requires no additional dependencies or infrastructure overhead, and it scales indefinitely as long as the quantity of session data being stored fits into a normal cookie.</div>
|
||||
|
||||
<div className="text">The biggest downside is that it places session data into storage on the user’s machine and transports it over the wire. It also limits the quantity of session data that can be stored.<br/>See the Django <span style={{textDecoration:'underline', color: '#0000b3'}}>cookie-based sessions</span> documentation.</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
59
docs/old-instance/tutorial-9.md
Normal file
@ -0,0 +1,59 @@
|
||||
---
|
||||
sidebar_label: 'Create and manage images'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import createImage from '@site/static/img/create-image.png';
|
||||
|
||||
|
||||
# Create and manage images
|
||||
|
||||
<div className="text">As an administrative user, you can create and manage images for the projects to which you belong. You can also create and manage images for users in all projects to which you have access.</div>
|
||||
<div className="text">To create and manage images in specified projects as an end user, see the <span style={{textDecoration:'underline', color: '#0000b3'}}>upload and manage images with Dashboard in OpenStack End User Guide</span> and <span style={{textDecoration:'underline', color: '#0000b3'}}>manage images with CLI in OpenStack End User Guide.</span></div>
|
||||
<div className="text">To create and manage images as an administrator for other users, use the following procedures.</div>
|
||||
|
||||
<div className="head">Create images</div>
|
||||
<div className="text">For details about image creation, see the <span style={{textDecoration:'underline', color: '#0000b3'}}> Virtual Machine Image Guide.</span></div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the Dashboard and select the <span className="blue">admin</span> project from the drop-down list.</li><li>On the <span className="blue">Admin</span> tab, open the Compute tab and click the <span className="blue">Images</span> category. The images that you can administer for cloud users appear on this page.</li><li>Click <span className="blue">Create Image</span>, which opens the <span className="blue">Create An Image</span> window.</li></ol></div>
|
||||
|
||||
|
||||
<img src={createImage} alt="My Image" />
|
||||
|
||||
<div className="text">4. In the <span className="text">Create An Image window, enter or select the following values:</span></div><br/>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Enter a name for the image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
<td>Enter a brief description of the image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image Source</td>
|
||||
<td>Choose the image source from the dropdown list. Your choices are Image Location and Image File.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image File or Image Location</td>
|
||||
<td>Based on your selection, there is an Image File or Image Location field. You can include the location URL or browse for the image file on your file system and add it.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Format</td>
|
||||
<td>Select the image format.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Architecture</td>
|
||||
<td>Specify the architecture. For example, i386 for a 32-bit architecture or x86_64 for a 64-bit architecture.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Minimum Disk (GB)</td>
|
||||
<td>Leave this field empty.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
49
docs/old-instance2.0/Cloudtopiaa Orchestration service.md
Normal file
@ -0,0 +1,49 @@
|
||||
---
|
||||
sidebar_label: "Cloudtopiaa Orchestration Service"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
|
||||
# Cloudtopiaa Orchestration Service
|
||||
|
||||
<div className="text">The Orchestration service provides a template-based orchestration for describing a cloud application by running OpenStack API calls to generate running cloud applications. The software integrates other core components of OpenStack into a one-file template system. The templates allow you to create most OpenStack resource types such as instances, floating IPs, volumes, security groups, and users. It also provides advanced functionality such as instance high availability, instance auto-scaling, and nested stacks. This enables OpenStack core projects to receive a larger user base.</div>
|
||||
|
||||
<div className="text">The service allows deployers to integrate with the Orchestration service directly or through custom plug-ins.</div>
|
||||
|
||||
<div className="head">Launch an instance</div>
|
||||
<div className="text">In environments that include the Orchestration service, you can create a stack that launches an instance.</div>
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Create a template</div>
|
||||
<div className="text">The Orchestration service uses templates to describe stacks. To learn about the template language, see the Template Guide.</div>
|
||||
|
||||
<div className="text"><ul><li>Create the demo-template.yml file with the following content:</li></ul></div>
|
||||
|
||||
<CodeBlock code={`heat_template_version: 2015-10-15
|
||||
description: Launch a basic instance with CirrOS image using the
|
||||
'm1.tiny' flavor, 'mykey' key, and one network.
|
||||
|
||||
parameters:
|
||||
NetID:
|
||||
type: string
|
||||
description: Network ID to use for the instance.
|
||||
|
||||
resources:
|
||||
server:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
image: cirros
|
||||
flavor: m1.tiny
|
||||
key_name: mykey
|
||||
networks:
|
||||
- network: { get_param: NetID }
|
||||
|
||||
outputs:
|
||||
instance_name:
|
||||
description: Name of the instance.
|
||||
value: { get_attr: [ server, name ] }
|
||||
instance_ip:
|
||||
description: IP address of the instance.
|
||||
value: { get_attr: [ server, first_address ] }
|
||||
`} />
|
||||
@ -0,0 +1,101 @@
|
||||
---
|
||||
sidebar_label: 'Configure access and security for instances'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import addrule from '@site/static/img/add-rule.png';
|
||||
import keypair from '@site/static/img/key-pair.png';
|
||||
import importkey from '@site/static/img/import-key.png';
|
||||
import floatip from '@site/static/img/float-ip.png';
|
||||
|
||||
|
||||
# Configure access and security for instances
|
||||
|
||||
<div className="text">Before you launch an instance, you should add security group rules to enable users to ping and use SSH to connect to the instance. Security groups are sets of IP filter rules that define networking access and are applied to all instances within a project. To do so, you either add rules to the default security group <span style={{textDecoration:'underline', color: '#0000b3' , }}>Add a rule to the default security</span> group or add a new security group with rules.</div>
|
||||
|
||||
<div className="text">Key pairs are SSH credentials that are injected into an instance when it is launched. To use key pair injection, the image that the instance is based on must contain the cloud-init package. Each project should have at least one key pair. For more information, see the section <span style={{textDecoration:'underline', color: '#0000b3'}}>Add a key pair</span>.</div>
|
||||
|
||||
<div className="text">If you have generated a key pair with an external tool, you can import it into OpenStack. The key pair can be used for multiple instances that belong to a project. For more information, see the section <span style={{textDecoration:'underline', color: '#0000b3'}}>Import a key pair</span>.</div><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: A key pair belongs to an individual user, not to a project. To share a key pair across multiple users, each user needs to import that key pair.</div><br/>
|
||||
|
||||
<div className="text">When an instance is created in cloudtopiaa, it is automatically assigned a fixed IP address in the network to which the instance is assigned. This IP address is permanently associated with the instance until the instance is terminated. However, in addition to the fixed IP address, a floating IP address can also be attached to an instance. Unlike fixed IP addresses, floating IP addresses are able to have their associations modified at any time, regardless of the state of the instances involved.</div>
|
||||
|
||||
|
||||
<div className="head">Add a rule to the default security group</div>
|
||||
<div className="text">This procedure enables SSH and ICMP (ping) access to instances. The rules apply to all instances within a given project, and should be set for every project unless there is a reason to prohibit SSH or ICMP access to the instances.</div>
|
||||
<div className="text">This procedure can be adjusted as necessary to add additional security group rules to a project, if your cloud requires them</div><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: When adding a rule, you must specify the protocol used with the destination port or source port.</div><br/>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Network</span> tab. The <span className="blue">Security Groups</span> tab shows the security groups that are available for this project.</li><li>Select the default security group and click <span className="blue">Manage Rules</span>.</li><li>To allow SSH access, click <span className="blue">Add Rule</span>.</li><li>In the <span className="blue">Add Rule</span> dialog box, enter the following values:<ul><li>Rule: SSH</li><li>Remote: CIDR</li><li>CIDR: 0.0.0.0/0</li></ul></li></ol></div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: To accept requests from a particular range of IP addresses, specify the IP address block in the <span className="blue">CIDR</span> box.</div>
|
||||
|
||||
<div className="text">7. Click <span className="blue">Add</span>.<br/>
|
||||
Instances will now have SSH port 22 open for requests from any IP address.
|
||||
To add an ICMP rule, click <span className="blue">Add Rule</span>.</div>
|
||||
|
||||
<div className="text">8. Click <span className="blue">Add</span>.<br/>
|
||||
Instances will now have SSH port 22 open for requests from any IP address.</div>
|
||||
|
||||
<div className="text">9. To add an ICMP rule, click <span className="blue">Add Rule</span>.</div>
|
||||
|
||||
<div className="text">10. In the <span className="blue">Add Rule</span> dialog box, enter the following values:<ul><li>Rule: All ICMP</li><li>Direction: Ingress
|
||||
</li><li>Remote: CIDR</li><li>CIDR: 0.0.0.0/0</li></ul></div>
|
||||
|
||||
<div className="text">11. Click<span className="blue">Add</span>.<br/>
|
||||
Instances will now accept all incoming ICMP packets.</div><br/>
|
||||
|
||||
|
||||
<img src={addrule} alt="Add Rule" />
|
||||
|
||||
|
||||
<div className="head">Add a key pair</div>
|
||||
<div className="text">Create at least one key pair for each project.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Compute</span> tab.</li><li>Click the <span className="blue">Key Pairs</span> tab, which shows the key pairs that are available for this project.
|
||||
</li><li>Click <span className="blue">Create Key Pair</span>.</li><li>In the <span className="blue">Create Key Pair</span> dialog box, enter a name for your key pair, and click Create Key Pair.</li><li>The private key will be downloaded automatically.</li></ol></div><br/>
|
||||
|
||||
|
||||
<img src={keypair} alt="Key Pair" />
|
||||
|
||||
|
||||
<div className="text">To change its permissions so that only you can read and write to the file, run the following command:</div>
|
||||
<CodeBlock code={`$ chmod 0600 yourPrivateKey.pem`} /><br/>
|
||||
|
||||
<div className="note"><strong>Note</strong>: If you are using the Dashboard from a Windows computer, use PuTTYgen to load the *.pem file and convert and save it as *.ppk. For more information see the <span style={{textDecoration:'underline', color: '#000066'}}>WinSCP web page for PuTTYgen.</span></div><br/>
|
||||
|
||||
<div className="text">To make the key pair known to SSH, run the ssh-add command.</div>
|
||||
|
||||
<CodeBlock code={`$ ssh-add yourPrivateKey.pem`} />
|
||||
|
||||
|
||||
<div className="head">Import a key pair</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Compute</span> tab.</li><li>Click the <span className="blue">Key Pairs</span> tab, which shows the key pairs that are available for this project.</li><li>Click <span className="blue">Import Key</span> Pair.</li><li>In the <span className="blue">Import Key Pair</span> dialog box, enter the name of your key pair, copy the <span className="blue">public key</span> into the Public Key box, and then click <span className="blue">Import Key Pair.</span></li></ol></div>
|
||||
|
||||
<div className="text">The Compute database registers the public key of the key pair.</div>
|
||||
<div className="text">The Dashboard lists the key pair on the <span className="blue">Key Pairs</span> tab.</div><br/>
|
||||
|
||||
<img src={importkey} alt="Import Key" />
|
||||
|
||||
<div className="head">Allocate a floating IP address to an instance</div>
|
||||
|
||||
<div className="text">When an instance is created in OpenStack, it is automatically assigned a fixed IP address in the network to which the instance is assigned. This IP address is permanently associated with the instance until the instance is terminated.</div>
|
||||
|
||||
<div className="text">However, in addition to the fixed IP address, a floating IP address can also be attached to an instance. Unlike fixed IP addresses, floating IP addresses can have their associations modified at any time, regardless of the state of the instances involved. This procedure details the reservation of a floating IP address from an existing pool of addresses and the association of that address with a specific instance.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Network</span> tab.</li><li>Click the <span className="blue">Floating IPs</span> tab, which shows the floating IP addresses allocated to instances.</li><li>Click <span className="blue">Allocate IP To Project</span>.</li><li>Choose the pool from which to pick the IP address.</li><li>Click <span className="blue">Allocate IP</span>.</li><li>In the <span className="blue">Floating IPs</span> list, click <span className="blue">Associate</span>.</li><li>In the <span className="blue">Manage Floating IP Associations</span> dialog box, choose the following options:<ul><li>The <span className="blue">IP Address</span> field is filled automatically, but you can add a new IP address by clicking the + button.</li><li>In the <span className="blue">Port to be associated</span> field, select a port from the list.<br/>The list shows all the instances with their fixed IP addresses.</li></ul></li><li>Click <span className="blue">Associate</span>.</li></ol></div>
|
||||
|
||||
|
||||
<div className="note"><strong>Note</strong>: To disassociate an IP address from an instance, click the Disassociate button.<br/>
|
||||
To release the floating IP address back into the floating IP pool, click the Release Floating IP option in the Actions column.</div><br/>
|
||||
|
||||
<img src={floatip} alt="Floating IP" />
|
||||
|
||||
|
||||
|
||||
|
||||
34
docs/old-instance2.0/Create and manage networks.md
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
sidebar_label: "Create and manage networks"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import createnetwork from '@site/static/img/create-network.png';
|
||||
import subnetnetwork from '@site/static/img/subnet-network.png';
|
||||
|
||||
|
||||
|
||||
# Create and manage networks
|
||||
|
||||
<div className="text">The OpenStack Networking service provides a scalable system for managing the network connectivity within an OpenStack cloud deployment. It can easily and quickly react to changing network needs (for example, creating and assigning new IP addresses).</div>
|
||||
|
||||
<div className="text">Networking in OpenStack is complex. This section provides the basic instructions for creating a network and a router. For detailed information about managing networks, refer to the OpenStack Networking Guide.</div>
|
||||
|
||||
<div className="head">Create a network</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Network</span> tab and click <span className="blue">Networks </span>category.</li><li>Click <span className="blue">Create Network</span>.</li><li>In the <span className="blue">Create Network</span> dialog box, specify the following values.<br/><span className="blue">Network</span> tab<br/><span className="blue">Network Name</span>: Specify a name to identify the network.<br/><span className="blue">Shared</span>: Share the network with other projects. Non admin users are not allowed to set shared option.<br/><span className="blue">Admin State</span>: The state to start the network in.<br/>
|
||||
<span className="blue">Create Subnet</span>: Select this check box to create a subnet<br/>You do not have to specify a subnet when you create a network, but if you do not specify a subnet, the network can not be attached to an instance.<br/><br/>
|
||||
<img src={createnetwork} alt="Create Network" /><br/><br/><span className="blue">Subnet</span> tab<br/><span className="blue">Subnet Name</span>: Specify a name for the subnet.<br/><span className="blue">Network Address</span>: Specify the IP address for the subnet.<br/><span className="blue">IP Version</span>: Select IPv4 or IPv6.<br/><span className="blue">Gateway IP</span>: Specify an IP address for a specific gateway. This parameter is optional.<br/><span className="blue">Disable Gateway</span>: Select this check box to disable a gateway IP address.<br/><br/> <img src={subnetnetwork} alt="Subnet Network"/><span className="blue">Subnet Details</span> tab<br/><span className="blue">Enable DHCP</span>: Select this check box to enable DHCP.<br/><span className="blue">Allocation Pools</span>: Specify IP address pools.<br/><span className="blue">DNS Name Servers</span>: Specify a name for the DNS server.<br/>Host Routes: Specify the IP address of host routes.</li><li>Click <span className="blue">Create</span>.<br/>The dashboard shows the network on the <span className="blue">Networks</span> tab.</li></ol></div><br/>
|
||||
|
||||
<div className="head">Create a router</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Network</span> tab and click <span className="blue">Routers </span>category.</li><li>Click <span className="blue">Create Router</span>.</li><li>In the <span className="blue">Create Router</span> dialog box, specify a name for the router and <span className="blue">External Network</span>, and click <span className="blue">Create Router</span>.<br/>The new router is now displayed in the <span className="blue">Routers</span> tab.</li><li>To connect a private network to the newly created router, perform the following steps:<br/>a. On the <span className="blue">Routers</span> tab, click the name of the router.<br/>b. On the <span className="blue">Router Details</span> page, click the <span className="blue">Interfaces</span> tab, then click <span className="blue">Add Interface</span>.<br/>c. In the <span className="blue">Add Interface</span> dialog box, select a Subnet.<br/>Optionally, in the <span className="blue">Add Interface</span> dialog box, set an <span className="blue">IP Address</span> for the router interface for the selected subnet.<br/>If you choose not to set the <span className="blue">IP Address</span> value, then by default OpenStack Networking uses the first host IP address in the subnet.<br/>The <span className="blue">Router Name</span> and <span className="blue">Router ID</span> fields are automatically updated.</li><li>Click Add Interface.</li></ol></div>
|
||||
<div className="text">You have successfully created the router. You can view the new topology from the Network Topology tab.</div>
|
||||
|
||||
|
||||
|
||||
<div className="head">Create a port</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop-down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, click <span className="blue">Networks</span> category.</li><li>Click on the <span className="blue">Network Name</span> of the network in which the port has to be created.</li><li>Go to the <span className="blue">Ports</span> tab and click <span className="blue">Create Port</span>.</li><li>In the Create Port dialog box, specify the following values.<br/><span className="blue">Name</span>: Specify name to identify the port<br/><span className="blue">Device ID</span>: Device ID attached to the port.<br/><span className="blue">Device Owner</span>: Device owner attached to the port.<br/><span className="blue">Binding Host</span>: The ID of the host where the port is allocated.<br/><span className="blue">Binding VNIC Type</span>: Select the VNIC type that is bound to the neutron port.</li><li>Click <span className="blue">Create Port</span>.<br/>The new port is now displayed in the Ports list.</li></ol></div>
|
||||
|
||||
81
docs/old-instance2.0/Create and manage object containers.md
Normal file
@ -0,0 +1,81 @@
|
||||
---
|
||||
sidebar_label: "Create and manage object containers"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import createcontainer from '@site/static/img/create-container.png';
|
||||
import uploadfilecontainer from '@site/static/img/uploadfile-container.png';
|
||||
import editfilecontainer from '@site/static/img/editfile-container.png';
|
||||
import copyfilecontainer from '@site/static/img/copy-container.png';
|
||||
|
||||
|
||||
|
||||
# Create and manage object containers
|
||||
|
||||
<div className="text">OpenStack Object Storage (swift) is used for redundant, scalable data storage using clusters of standardized servers to store petabytes of accessible data. It is a long-term storage system for large amounts of static data which can be retrieved and updated.</div>
|
||||
|
||||
<div className="text">OpenStack Object Storage provides a distributed, API-accessible storage platform that can be integrated directly into an application or used to store any type of file, including VM images, backups, archives, or media files. In the OpenStack dashboard, you can only manage containers and objects.</div>
|
||||
|
||||
<div className="text">In OpenStack Object Storage, containers provide storage for objects in a manner similar to a Windows folder or Linux file directory, though they cannot be nested. An object in OpenStack consists of the file to be stored in the container and any accompanying metadata.</div>
|
||||
|
||||
|
||||
<div className="head">Create a container</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers </span>category.</li><li>Click <span className="blue">Container</span>.</li><li>In the <span className="blue">Create Container</span> dialog box, enter a name for the container, and then click <span className="blue">Create</span>.</li></ol></div>
|
||||
|
||||
<div className="text">You have successfully created a container.</div>
|
||||
|
||||
|
||||
<div className="note"><strong>Note</strong>: To delete a container, click the More button and select Delete Container.</div><br/>
|
||||
|
||||
<img src={createcontainer} alt="create Container" /><br/><br/>
|
||||
|
||||
|
||||
<div className="head">Upload an object</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Select the container in which you want to store your object.</li><li>Click the <span className="blue">Upload File</span> icon.<br/>The <span className="blue">Upload File To Container: <name></span> dialog box appears. <name> is the name of the container to which you are uploading the object.</li><li>Enter a name for the object.</li><li>Browse to and select the file that you want to upload.</li><li>Click <span className="blue">Upload File</span>.</li></ol></div>
|
||||
|
||||
<div className="text">You have successfully uploaded an object to the container.</div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: To delete an object, click the More button and select Delete Object.</div><br/>
|
||||
|
||||
<img src={uploadfilecontainer} alt="Upload files to Container" /><br/><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="head">Manage an object</div>
|
||||
<strong>To edit an object</strong>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Select the container in which you want to store your object.</li><li>Click the menu button and choose <span className="blue">Edit</span> from the dropdown list.<br/>The <span className="blue">Edit Object</span> dialog box is displayed.</li><li>Browse to and select the file that you want to upload.</li><li>Click Update Object.</li></ol></div><br/>
|
||||
<img src={editfilecontainer} alt="Edit files Container" /><br/><br/>
|
||||
|
||||
|
||||
<div className="note"><strong>Note</strong>: To delete an object, click the menu button and select Delete Object.</div><br/>
|
||||
|
||||
<strong>To copy an object from one container to another</strong>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Select the container in which you want to store your object.</li><li>Click the menu button and choose <span className="blue">Copy</span> from the dropdown list.</li><li>In the <span className="blue">Copy Object</span> launch dialog box, enter the following values:<ul><li><span className="blue">Destination Container</span>: Choose the destination container from the list.</li><li><span className="blue">Path</span>: Specify a path in which the new copy should be stored inside of the selected container.</li><li><span className="blue">Destination object name</span>: Enter a name for the object in the new container.</li></ul></li><li>Click <span className="blue">Copy Object</span>.</li></ol></div><br/>
|
||||
|
||||
<img src={copyfilecontainer} alt="Copy file Container" /><br/><br/>
|
||||
|
||||
|
||||
<strong>To create a metadata-only object without a file</strong>
|
||||
|
||||
<div className="text">You can create a new object in container without a file available and can upload the file later when it is ready. This temporary object acts a place-holder for a new object, and enables the user to share object metadata and URL info in advance.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers </span>category.</li><li>Select the container in which you want to store your object.</li><li>Click <span className="blue">Upload Object</span>.<br/>The <span className="blue">Upload Object To Container</span>: <name> dialog box is displayed.<br/><name> is the name of the container to which you are uploading the object.</li><li>Enter a name for the object.</li><li>Click <span className="blue">Update Object</span>.</li></ol></div><br/>
|
||||
|
||||
<strong>To create a pseudo-folder</strong>
|
||||
<div className="text">Pseudo-folders are similar to folders in your desktop operating system. They are virtual collections defined by a common prefix on the object’s name.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Object Store</span> tab and click <span className="blue">Containers</span> category.</li><li>Select the container in which you want to store your object.</li><li>Click <span className="blue">Create Pseudo-folder</span>. <br/>The <span className="blue">Create Pseudo-Folder in Container</span> <name> dialog box is displayed. <name> is the name of the container to which you are uploading the object.</li><li>Enter a name for the pseudo-folder. <br/>A slash (/) character is used as the delimiter for pseudo-folders in Object Storage.</li><li>Click <span className="blue">Create</span>.</li></ol></div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
84
docs/old-instance2.0/Create and manage volumes.md
Normal file
@ -0,0 +1,84 @@
|
||||
---
|
||||
sidebar_label: "Create and manage volumes"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import createvolume from '@site/static/img/create-volume.png';
|
||||
import managevolume from '@site/static/img/manage-volume.png';
|
||||
import detachvolume from '@site/static/img/detach-volume.png';
|
||||
import createvolumesnapshot from '@site/static/img/create-volume-snapshot.png';
|
||||
import editvolume from '@site/static/img/edit-volume.png';
|
||||
import deletevolume from '@site/static/img/delete-volume.png';
|
||||
import createcontainer from '@site/static/img/create-container.png';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Create and manage volumes
|
||||
|
||||
<div className="text">Volumes are block storage devices that you attach to instances to enable persistent storage. You can attach a volume to a running instance or detach a volume and attach it to another instance at any time. You can also create a snapshot from or delete a volume. Only administrative users can create volume types.</div>
|
||||
|
||||
<div className="head">Create a volume</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Volumes</span> tab and click <span className="blue">Volumes </span>category.</li><li>Click <span className="blue">Create Volume</span>.<br/>In the dialog box that opens, enter or select the following values.<br/><span className="blue">Volume Name</span>: Specify a name for the volume.<br/><span className="blue">Description</span>: Optionally, provide a brief description for the volume.<br/><span className="blue">Volume Source</span>: Select one of the following options:<ul><li>No source, empty volume: Creates an empty volume. An empty volume does not contain a file system or a partition table.</li><li>Snapshot: If you choose this option, a new field for <span className="blue">Use snapshot as a source</span> displays. You can select the snapshot from the list.</li><li>Image: If you choose this option, a new field for <span className="blue">Use image as a source</span> displays. You can select the image from the list.</li><li>Volume: If you choose this option, a new field for <span className="blue">Use volume as a source</span> displays. You can select the volume from the list. Options to use a snapshot or a volume as the source for a volume are displayed only if there are existing snapshots or volumes.</li></ul><span className="blue">Type</span>: Leave this field blank.<br/><span className="blue">Size (GB)</span>: The size of the volume in gibibytes (GiB).<br/><span className="blue">Availability Zone</span>: Select the Availability Zone from the list. By default, this value is set to the availability zone given by the cloud provider (for example, us-west or apac-south). For some cases, it could be nova.</li><li>Click <span className="blue">Create Volume</span>.</li></ol></div>
|
||||
<div className="text">The dashboard shows the volume on the <span className="blue">Volumes</span> tab.</div><br/>
|
||||
|
||||
<img src={createvolume} alt="create Volume" /><br/><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="head">Attach a volume to an instance</div>
|
||||
|
||||
<div className="text">After you create one or more volumes, you can attach them to instances. You can attach a volume to one instance at a time.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Volumes</span> tab and click <span className="blue">Volumes</span> category.</li><li>Select the volume to add to an instance and click <span className="blue">Manage Attachments</span>.</li><li>In the <span className="blue">Manage Volume Attachments</span> dialog box, select an instance.</li><li>Enter the name of the device from which the volume is accessible by the instance.</li><div className="note"><strong>Note</strong>: The actual device name might differ from the volume name because of hypervisor settings.</div><br/><li>Click <span className="blue">Attach Volume</span>.<br/>The dashboard shows the instance to which the volume is now attached and the device name.</li></ol></div>
|
||||
|
||||
<img src={managevolume} alt="manage Volume" /><br/><br/>
|
||||
|
||||
|
||||
<div className="text">You can view the status of a volume in the Volumes tab of the dashboard. The volume is either Available or In-Use.<br/>
|
||||
Now you can log in to the instance and mount, format, and use the disk.</div>
|
||||
|
||||
|
||||
|
||||
<div className="head">Detach a volume from an instance</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Volumes</span> tab and click the <span className="blue">Volumes</span> category.</li><li>Select the volume and click <span className="blue">Manage Attachments</span>.</li><li>Click <span className="blue">Detach Volume</span> and confirm your changes.</li></ol></div>
|
||||
|
||||
<div className="text">A message indicates whether the action was successful.</div>
|
||||
|
||||
<img src={detachvolume} alt="Detach Volume" /><br/>
|
||||
|
||||
|
||||
<div className="head">Create a snapshot from a volume</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Volumes</span> tab and click <span className="blue">Volumes </span>category.</li><li>Select a volume from which to create a snapshot.</li><li>In the <span className="blue">Actions</span> column, click <span className="blue">Create Snapshot</span>.</li><li>In the dialog box that opens, enter a snapshot name and a brief description.</li><li>Confirm your changes.<br/>The dashboard shows the new volume snapshot in Volume Snapshots tab.</li></ol></div>
|
||||
|
||||
|
||||
<img src={createvolumesnapshot} alt="Create Volume Snapshot" /><br/>
|
||||
|
||||
|
||||
<div className="head">Edit a volume</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Volumes</span> tab and click <span className="blue">Volumes</span> category.</li><li>Select the volume that you want to edit.</li><li>In the <span className="blue">Actions</span> column, click <span className="blue">Edit Volume</span>.</li><li>In the <span className="blue">Edit Volume</span> dialog box, update the name and description of the volume.</li><li>Click <span className="blue">Edit Volume</span>.</li></ol></div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: You can extend a volume by using the Extend Volume option available in the More dropdown list and entering the new value for volume size.</div><br/>
|
||||
|
||||
<img src={editvolume} alt="Edit Volume " /><br/>
|
||||
|
||||
|
||||
<div className="head">Delete a volume</div>
|
||||
|
||||
<div className="text">When you delete an instance, the data in its attached volumes is not deleted.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Volumes</span> tab and click <span className="blue">Volumes</span> category.</li><li>Select the check boxes for the volumes that you want to delete.</li><li>Click <span className="blue">Delete Volumes</span> and confirm your choice. <br/>A message indicates whether the action was successful.</li></ol></div>
|
||||
|
||||
<img src={deletevolume} alt="Delete Volume " /><br/>
|
||||
|
||||
|
||||
86
docs/old-instance2.0/Launch and manage instances.md
Normal file
@ -0,0 +1,86 @@
|
||||
---
|
||||
sidebar_label: "Launch and manage instances"
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import launchinstance from '@site/static/img/launch-instance.png';
|
||||
import sourcetab from '@site/static/img/source-tab.png';
|
||||
import flavor from '@site/static/img/flavor.png';
|
||||
import network from '@site/static/img/network.png';
|
||||
import networkport from '@site/static/img/network-port.png';
|
||||
import securitygroup from '@site/static/img/security-group.png';
|
||||
import keypair from '@site/static/img/key-pair2.png';
|
||||
import configuration from '@site/static/img/configuration.png';
|
||||
|
||||
# Launch and manage instances
|
||||
|
||||
<div className="text">Instances are virtual machines that run inside the cloud. You can launch an instance from the following sources: <ul><li>Images uploaded to the Image service.
|
||||
</li><li>Image that you have copied to a persistent volume.</li><li>Instance snapshot that you took.</li></ul></div>
|
||||
|
||||
<div className="head">Launch an instance</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.
|
||||
</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Compute</span> tab and click <span className="blue">Instances</span> category.<br/>
|
||||
The dashboard shows the instances with its name, its private and floating IP addresses, size, status, task, power state, and so on.</li><li>Click <span className="blue">Launch Instance</span>.</li><li>In the <span className="blue">Launch Instance</span> dialog box, specify the following values:<br/>
|
||||
<span className="blue">Details</span> tab<br/><br/>
|
||||
<img src={launchinstance} alt="Launch Instance" /><strong>Instance Name</strong><br/>Assign a name to the virtual machine.<br/><div className="note"><strong>Note:</strong> The name you assign here becomes the initial host name of the server. If the name is longer than 63 characters, the Compute service truncates it automatically to ensure dnsmasq works correctly.<br/>After the server is built, if you change the server name in the API or change the host name directly, the names are not updated in the dashboard.<br/>Server names are not guaranteed to be unique when created so you could have two instances with the same host name.</div><br/><strong>Description</strong><br/>You can assign a brief description of the virtual machine.<br/><strong>Availability Zone</strong><br/>By default, this value is set to the availability zone given by the cloud provider (for example, us-west or apac-south). For some cases, it could be nova.<br/><strong>Count</strong><br/>To launch multiple instances, enter a value greater than 1. The default is<br/> 1.
|
||||
<span className="blue">Source</span> tab<br/><strong>Instance Boot Source</strong><br/>Your options are:<br/><br/><strong>Boot from image</strong></li>If you choose this option, a new field for <span className="blue">Image Name</span> displays. You can select the image from the list.<br/><strong>Boot from snapshot</strong><br/>If you choose this option, a new field for <span className="blue">Instance Snapshot</span> displays. You can select the snapshot from the list.<br/><strong>Boot from volume</strong><br/>If you choose this option, a new field for <span className="blue">Volume</span> displays. You can select the volume from the list.<br/><strong>Boot from image (creates a new volume)</strong><br/>With this option, you can boot from an image and create a volume by entering the <span className="blue">Device Size</span> and <span className="blue">Device Name</span> for your volume. Click the <span className="blue">Delete Volume on Instance Delete</span> option to delete the volume on deleting the instance.<br/><strong>Boot from volume snapshot (creates a new volume)</strong><br/>Using this option, you can boot from a volume snapshot and create a new volume by choosing <span className="blue">Volume Snapshot</span> from a list and adding a <span className="blue">Device Name</span> for your volume. Click the <span className="blue">Delete Volume on Instance Delete</span> option to delete the volume on deleting the instance.<br/><strong>Image Name</strong><br/>This field changes based on your previous selection. If you have chosen to launch an instance using an image, the <span className="blue">Image Name</span> field displays. Select the image name from the dropdown list.<br/><strong>Instance Snapshot</strong><br/>This field changes based on your previous selection. If you have chosen to launch an instance using a snapshot, the <span className="blue">Instance Snapshot</span> field displays. Select the snapshot name from the dropdown list.<br/><strong>Volume</strong><br/>This field changes based on your previous selection. If you have chosen to launch an instance using a volume, the <span className="blue">Volume</span> field displays. Select the volume name from the dropdown list. If you want to delete the volume on instance delete, check the <span className="blue">Delete Volume on Instance Delete</span> option.<br/><br/><img src={sourcetab} alt="Source Tab" /><br/><br/>
|
||||
<span className="blue">Flavor</span> tab<br/><strong>Flavor</strong><br/>Specify the size of the instance to launch.<br/><div className="note"><strong>Note</strong>: The flavor is selected based on the size of the image selected for launching an instance. For example, while creating an image, if you have entered the value in the Minimum RAM (MB) field as 2048, then on selecting the image, the default flavor is m1.small.</div><br/><img src={flavor} alt="Flavor" /><br/><br/>
|
||||
<span className="blue">Networks </span>tab<br/><strong>Selected Networks</strong><br/>To add a network to the instance, click the + in the Available field.<br/><img src={network} alt="Network" /><br/><br/><span className="blue">Network Ports</span> tab<br/><strong>Ports</strong><br/>Activate the ports that you want to assign to the instance.<br/> <img src={networkport} alt="Network Port" /><br/><br/>
|
||||
<span className="blue">Security Groups</span> tab<br/><strong>Security Groups</strong><br/>Activate the security groups that you want to assign to the instance.<br/>
|
||||
Security groups are a kind of cloud firewall that define which incoming network traffic is forwarded to instances.<br/>If you have not created any security groups, you can assign only the default security group to the instance.<br/><img src={securitygroup} alt="Security Group" /><br/><br/><span className="blue">Key Pair </span>tab<br/><strong>Key Pair</strong><br/>Specify a key pair.<br/>If the image uses a static root password or a static key set (neither is recommended), you do not need to provide a key pair to launch the instance.<br/><img src={keypair} alt="Key Pair" /><br/><br/><span className="blue">Configuration</span> tab<br/><strong>Customization Script Source</strong><br/>Specify a customization script that runs after your instance launches.<br/><img src={keypair} alt="Key Pair" /><br/><br/><span className="blue">Metadata </span>tab<br/><strong>Available Metadata
|
||||
</strong><br/>Add Metadata items to your instance.<li>Click <span className="blue">Launch Instance.</span><br/>The instance starts on a compute node in the cloud.</li></ol></div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: If you did not provide a key pair, security groups, or rules, users can access the instance only from inside the cloud through VNC. Even pinging the instance is not possible without an ICMP rule configured.</div>
|
||||
|
||||
<div className="text">You can also launch an instance from the <span className="blue">Images</span> or <span className="blue">Volumes</span> category when you launch an instance from an image or a volume respectively.</div>
|
||||
|
||||
<div className="text">When you launch an instance from an image, OpenStack creates a local copy of the image on the compute node where the instance starts.</div>
|
||||
|
||||
<div className="text">For details on creating images, see <span style={{textDecoration:'underline', color: '#0000b3'}}>Creating images manually</span> in the OpenStack Virtual Machine Image Guide.</div>
|
||||
|
||||
<div className="text">When you launch an instance from a volume, note the following steps:</div>
|
||||
|
||||
<div className="text"><ul><li>To select the volume from which to launch, launch an instance from an arbitrary image on the volume. The arbitrary image that you select does not boot. Instead, it is replaced by the image on the volume that you choose in the next steps.
|
||||
To boot a Xen image from a volume, the image you launch in must be the same type, fully<br/>virtualized or paravirtualized, as the one on the volume</li><li>Select the volume or volume snapshot from which to boot. Enter a device name. Enter vda for KVM images or xvda for Xen images.</li></ul></div>
|
||||
|
||||
<div className="note"><strong>Note</strong>: When running QEMU without support for the hardware virtualization, set cpu_mode="none" alongside virt_type=qemu in /etc/nova/nova-compute.conf to solve the following error:</div>
|
||||
|
||||
<CodeBlock code={`libvirtError: unsupported configuration: CPU mode 'host-model'
|
||||
for 'x86_64' qemu domain on 'x86_64' host is not supported by hypervisor
|
||||
`} />
|
||||
|
||||
<div className="head">Connect to your instance by using SSH</div>
|
||||
|
||||
<div className="text">To use SSH to connect to your instance, use the downloaded keypair file.</div>
|
||||
<div className="note"><strong>Note</strong>: The user name is ubuntu for the Ubuntu cloud images on TryStack.</div>
|
||||
|
||||
<div className="text">1. Copy the IP address for your instance.</div>
|
||||
<div className="text">Use the ssh command to make a secure connection to the instance. For example:</div>
|
||||
|
||||
<CodeBlock code={`$ ssh -i MyKey.pem ubuntu@10.0.0.2
|
||||
`} />
|
||||
|
||||
<div className="text">2.At the prompt, type yes. </div>
|
||||
|
||||
<div className="text">It is also possible to SSH into an instance without an SSH keypair, if the administrator has enabled root password injection. For more information about root password injection, see <span style={{textDecoration:'underline', color: '#0000b3'}}>Injecting the administrator password</span> in the OpenStack Administrator Guide.</div>
|
||||
|
||||
<div className="head">Track usage for instances</div>
|
||||
|
||||
<div className="text">You can track usage for instances for each project. You can track costs per month by showing meters like number of vCPUs, disks, RAM, and uptime for all your instances.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Compute</span> tab and click <span className="blue">Overview</span> category.</li><li>To query the instance usage for a month, select a month and click <span className="blue">Submit</span>.</li><li>To download a summary, click <span className="blue">Download CSV Summary</span>.</li></ol></div>
|
||||
|
||||
<div className="head">Create an instance snapshot</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Compute</span> tab and click the Instances category.</li><li>Select the instance from which to create a snapshot.</li><li>In the actions column, click <span className="blue">Create Snapshot</span>.</li><li>In the <span className="blue">Create Snapshot</span> dialog box, enter a name for the snapshot, and click <span className="blue">Create Snapshot</span>.<br/>The <span className="blue">Images</span> category shows the instance snapshot.</li></ol></div>
|
||||
|
||||
<div className="text">To launch an instance from the snapshot, select the snapshot and click <span className="blue">Launch</span>. Proceed with launching an instance.</div>
|
||||
|
||||
<div className="head">Manage an instance</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Compute</span> tab and click <span className="blue">Instances</span> category.</li><li>Select an instance.</li><li>In the menu list in the actions column, select the state.
|
||||
You can resize or rebuild an instance. You can also choose to view the instance console log, edit instance or the security groups. Depending on the current state of the instance, you can pause, resume, suspend, soft or hard reboot, or terminate it.</li></ol></div>
|
||||
107
docs/old-instance2.0/manage-Images.md
Normal file
@ -0,0 +1,107 @@
|
||||
---
|
||||
sidebar_label: 'Upload and manage Images'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import createImage from '@site/static/img/create-image-2.png';
|
||||
import updateImage from '@site/static/img/update-image.png';
|
||||
import deleteImage from '@site/static/img/delete-image.png';
|
||||
|
||||
|
||||
|
||||
|
||||
# Upload and manage Images
|
||||
|
||||
<div className="text">An image is a file that contains a virtual disk with an operating system that can be used to start a virtual machine in the cloud.</div>
|
||||
|
||||
<div className="text">Based on your role, you might be allowed to upload and manage these images. Sometimes, only cloud administrators or operators are allowed to do this. If you have the right permissions, you can use the dashboard in the admin project to upload and manage images.</div><br/>
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Upload an image</div>
|
||||
<div className="text">Follow this procedure to upload an image to a project:</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Compute</span> tab and click <span className="blue">Images</span> category.</li><li>Click Create Image.<br/>
|
||||
The <span className="blue">Create An Image</span> dialog box appears.</li></ol></div><br/>
|
||||
|
||||
<img src={createImage} alt="create Image" /><br/><br/>
|
||||
|
||||
<div className="text">5. Enter the following values:</div>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span className="blue">Image Name</span></td>
|
||||
<td>Enter a name for the image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Image Description</span></td>
|
||||
<td>Enter a brief description of the image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Image Source</span></td>
|
||||
<td>Choose the image source from the dropdown list. Your choices are <span className="blue">Image Location</span> and <span className="blue">Image File</span>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Image File or Image Location</span></td>
|
||||
<td>Based on your selection for <span className="blue">Image Source</span>, you either enter the location URL of the image in the <span className="blue">Image Location</span> field, or browse for the image file on your file system and add it.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Format</span></td>
|
||||
<td>Select the image format (for example, QCOW2) for the image.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Architecture</span></td>
|
||||
<td>Specify the architecture. For example, i386 for a 32-bit architecture or x86_64 for a 64-bit architecture.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Minimum Disk (GB)</span></td>
|
||||
<td>Leave this field empty.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Minimum RAM (MB)</span></td>
|
||||
<td>Leave this field empty.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Copy Data</span></td>
|
||||
<td>Specify this option to copy image data to the Image service</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Visibility</span></td>
|
||||
<td>The access permission for the image. <span style={{ fontWeight: 'bold', color: 'green' }}>Public</span> or Private.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Protected</span></td>
|
||||
<td>Select this check box to ensure that only users with permissions can delete the image. Yes or No.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span className="blue">Image Metadata</span></td>
|
||||
<td>Specify this option to add resource metadata. The cloudtopiaa Metadata Catalog provides a list of metadata image definitions.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div className="text">6. Click <span className="blue">Create Image</span>.<br/>
|
||||
The image is queued to be uploaded. It might take some time before the status changes from Queued to Active.</div>
|
||||
|
||||
|
||||
<div className="head">Update an image</div>
|
||||
<div clssName="text">Follow this procedure to update an existing image.</div>
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>Select the image that you want to edit.</li><li>In the <span className="blue">Actions</span> column, click the menu button and then select <span className="blue">Edit Image</span> from the list.
|
||||
</li><li>In the <span className="blue">Edit Image</span> dialog box, you can perform various actions. For example:<ul><li>Change the name of the image.</li><li>Change the description of the image.</li><li>Change the format of the image.</li><li>Change the minimum disk of the image.</li><li>Change the minimum RAM of the image.</li><li>Select the <span className="blue">Public</span> button to make the image public.</li><li>Clear the <span className="blue">Private</span> button to make the image private.</li><li>Change the metadata of the image.</li></ul></li><li>Click <span className="blue">Edit Image</span>.</li></ol></div><br/>
|
||||
|
||||
<img src={updateImage} alt="update Image" /><br/><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="head">Delete an image</div>
|
||||
<div className="text">Deletion of images is permanent and <strong>cannot</strong> be reversed. Only users with the appropriate permissions can delete images.</div>
|
||||
|
||||
<div className="text"><ol><li>Log in to the dashboard.</li><li>Select the appropriate project from the drop down menu at the top left.</li><li>On the <span className="blue">Project</span> tab, open the <span className="blue">Compute</span> tab and click <span className="blue">Images</span> category.</li><li>Select the images that you want to delete.</li><li>Click <span className="blue">Delete Images</span></li><li>In the <span className="blue">Confirm Delete Images</span> dialog box, click <span className="blue">Delete Images</span> to confirm the deletion.</li></ol></div>
|
||||
|
||||
|
||||
<img src={deleteImage} alt="delete Image" /><br/><br/>
|
||||
136
docs/old-instance2.0/understanding.md
Normal file
@ -0,0 +1,136 @@
|
||||
---
|
||||
sidebar_label: 'Understanding Cloudtopiaa Dashboard'
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
<!-- truncate -->
|
||||
import CodeBlock from '@site/src/components/CodeBloack';
|
||||
import createImage from '@site/static/img/overview.png';
|
||||
import project from '@site/static/img/project-1.png';
|
||||
import volume from '@site/static/img/volume-1.png';
|
||||
import volume2 from '@site/static/img/volume-2.png';
|
||||
import network from '@site/static/img/network.png';
|
||||
import container from '@site/static/img/container.png';
|
||||
import stack from '@site/static/img/stack.png';
|
||||
import file from '@site/static/img/file.png';
|
||||
|
||||
|
||||
|
||||
# Understanding Cloudtopiaa Dashboard
|
||||
|
||||
|
||||
|
||||
<div className="text">In Cloudtopiaa, projects are like organizational units, also called tenants or accounts. Every user belongs to one or more projects where they can create and manage their instances. From the 'Project' tab, you can easily see and control the resources for a project, such as instances and images. To switch between projects, just use the drop-down menu in the top left corner.</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="head">Cloudtopiaa Dashboard</div>
|
||||
|
||||
<!-- project Tab -->
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Project tab</div>
|
||||
|
||||
<div className="text">In Cloudtopiaa, projects are like groups or accounts. Each user belongs to one or more projects where they can create and manage instances.</div>
|
||||
<div className="text">In the <span className="blue">Project</span> tab, you can view and manage the resources for a project, such as instances and images. To choose a project, use the drop-down menu in the top left corner.</div>
|
||||
<div className="text">From the <a href="https://console.blr.cloudtopiaa.com/project/" style={{textDecoration: 'underline', color: '#0000b3'}}>Project</a> tab, you can access the following categories:</div><br/>
|
||||
|
||||
<img src={createImage} alt="overview" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- compute Tab -->
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Compute tab</div>
|
||||
<div className="text"><ul><li>Overview: View reports for the project.</li><li>Instances: View, launch, create a snapshot from, stop, pause, or reboot instances, or connect to them through VNC.</li><li>Images: View images and instance snapshots created by project users, plus any images that are publicly available. Create, edit, and delete images, and launch instances from images and snapshots.</li><li>Key Pairs: View, create, edit, import, and delete key pairs.</li></ul></div>
|
||||
|
||||
<div className="text">Read more about the compute tab.</div><br/>
|
||||
|
||||
|
||||
<img src={project} alt="project" />
|
||||
|
||||
|
||||
|
||||
<!-- volume Tab -->
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Volume tab</div>
|
||||
|
||||
<div className="text"><ul><li><span className="blue">Volumes</span>: View, create, edit, and delete volumes.</li><li><span className="blue">Backups</span>: View, create, edit, and delete backups.</li><li><span className="blue">Snapshots</span>: View, create, edit, and delete volume snapshots.</li><li><span className="blue">Consistency Groups</span>: View, create, edit, and delete consistency groups.
|
||||
</li><li><span className="blue">Consistency Group Snapshots</span>: View, create, edit, and delete consistency group snapshots.</li></ul></div>
|
||||
|
||||
<div className="text">Read more about the Volume tab.</div><br/>
|
||||
|
||||
<img src={volume} alt="project" /><br/><br/>
|
||||
|
||||
<img src={volume2} alt="project" /><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- network Tab -->
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Network tab</div>
|
||||
|
||||
<div className="text"><ul><li><span className="blue">Network Topology</span>: View the network topology.</li><li><span className="blue">Networks</span>: Create and manage public and private networks.</li><li><span className="blue">Routers</span>: Create and manage routers.</li><li><span className="blue">Security Groups</span>: View, create, edit, and delete security groups and security group rules..</li><li><span className="blue">Floating IPs</span>: Allocate an IP address to or release it from a project.</li></ul></div>
|
||||
|
||||
<div className="text">Read more about Network tab</div><br/>
|
||||
|
||||
<img src={network} alt="project" /><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Object Store tab -->
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Object Store tab</div>
|
||||
|
||||
<div className="text"><ul><li><span className="blue">Containers</span>: Create and manage containers and objects.</li></ul></div>
|
||||
|
||||
<div className="text">Read more about Network tab</div><br/>
|
||||
|
||||
<img src={container} alt="project" /><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Infra Orchestration </div>
|
||||
|
||||
<div className="text"><ul><li><strong>Stacks</strong>: Groups of cloud resources (like servers, networks, and storage) managed together as one unit.</li><li><strong>Resource Types</strong>: Different kinds of cloud resources you can include in a stack, such as instances, volumes, or networks.</li><li><strong>Template Version</strong>: Specifies the version of the orchestration template format you're using to define resources.
|
||||
</li><li><strong>Template Generator</strong>: A tool that helps create orchestration templates, which define how resources are set up and managed in the cloud.</li></ul></div>
|
||||
|
||||
<div className="text">Read more about infra orchestration</div><br/>
|
||||
|
||||
<img src={stack} alt="project" /><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="text" style={{ fontSize:'28px' }}>Share</div>
|
||||
<div className="text">In cloudtopiaa share is the service that provides Shared File Systems as a service</div>
|
||||
<div className="text"><ul><li><strong>File system</strong>: These are the actual shared file systems that users can create and mount on instances.</li></ul></div>
|
||||
|
||||
<img src={file} alt="project" /><br/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8
docs/tutorial-basics/_category_.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"label": "Tutorial - Basics",
|
||||
"position": 2,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "5 minutes to learn the most important Docusaurus concepts."
|
||||
}
|
||||
}
|
||||
23
docs/tutorial-basics/congratulations.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
sidebar_position: 6
|
||||
---
|
||||
|
||||
# Congratulations!
|
||||
|
||||
You have just learned the **basics of Docusaurus** and made some changes to the **initial template**.
|
||||
|
||||
Docusaurus has **much more to offer**!
|
||||
|
||||
Have **5 more minutes**? Take a look at **[versioning](../tutorial-extras/manage-docs-versions.md)** and **[i18n](../tutorial-extras/translate-your-site.md)**.
|
||||
|
||||
Anything **unclear** or **buggy** in this tutorial? [Please report it!](https://github.com/facebook/docusaurus/discussions/4610)
|
||||
|
||||
## What's next?
|
||||
|
||||
- Read the [official documentation](https://docusaurus.io/)
|
||||
- Modify your site configuration with [`docusaurus.config.js`](https://docusaurus.io/docs/api/docusaurus-config)
|
||||
- Add navbar and footer items with [`themeConfig`](https://docusaurus.io/docs/api/themes/configuration)
|
||||
- Add a custom [Design and Layout](https://docusaurus.io/docs/styling-layout)
|
||||
- Add a [search bar](https://docusaurus.io/docs/search)
|
||||
- Find inspirations in the [Docusaurus showcase](https://docusaurus.io/showcase)
|
||||
- Get involved in the [Docusaurus Community](https://docusaurus.io/community/support)
|
||||
34
docs/tutorial-basics/create-a-blog-post.md
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
# Create a Blog Post
|
||||
|
||||
Docusaurus creates a **page for each blog post**, but also a **blog index page**, a **tag system**, an **RSS** feed...
|
||||
|
||||
## Create your first Post
|
||||
|
||||
Create a file at `blog/2021-02-28-greetings.md`:
|
||||
|
||||
```md title="blog/2021-02-28-greetings.md"
|
||||
---
|
||||
slug: greetings
|
||||
title: Greetings!
|
||||
authors:
|
||||
- name: Joel Marcey
|
||||
title: Co-creator of Docusaurus 1
|
||||
url: https://github.com/JoelMarcey
|
||||
image_url: https://github.com/JoelMarcey.png
|
||||
- name: Sébastien Lorber
|
||||
title: Docusaurus maintainer
|
||||
url: https://sebastienlorber.com
|
||||
image_url: https://github.com/slorber.png
|
||||
tags: [greetings]
|
||||
---
|
||||
|
||||
Congratulations, you have made your first post!
|
||||
|
||||
Feel free to play around and edit this post as much as you like.
|
||||
```
|
||||
|
||||
A new blog post is now available at [http://localhost:3000/blog/greetings](http://localhost:3000/blog/greetings).
|
||||
57
docs/tutorial-basics/create-a-document.md
Normal file
@ -0,0 +1,57 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Create a Document
|
||||
|
||||
Documents are **groups of pages** connected through:
|
||||
|
||||
- a **sidebar**
|
||||
- **previous/next navigation**
|
||||
- **versioning**
|
||||
|
||||
## Create your first Doc
|
||||
|
||||
Create a Markdown file at `docs/hello.md`:
|
||||
|
||||
```md title="docs/hello.md"
|
||||
# Hello
|
||||
|
||||
This is my **first Docusaurus document**!
|
||||
```
|
||||
|
||||
A new document is now available at [http://localhost:3000/docs/hello](http://localhost:3000/docs/hello).
|
||||
|
||||
## Configure the Sidebar
|
||||
|
||||
Docusaurus automatically **creates a sidebar** from the `docs` folder.
|
||||
|
||||
Add metadata to customize the sidebar label and position:
|
||||
|
||||
```md title="docs/hello.md" {1-4}
|
||||
---
|
||||
sidebar_label: 'Hi!'
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
# Hello
|
||||
|
||||
This is my **first Docusaurus document**!
|
||||
```
|
||||
|
||||
It is also possible to create your sidebar explicitly in `sidebars.js`:
|
||||
|
||||
```js title="sidebars.js"
|
||||
export default {
|
||||
tutorialSidebar: [
|
||||
'intro',
|
||||
// highlight-next-line
|
||||
'hello',
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Tutorial',
|
||||
items: ['tutorial-basics/create-a-document'],
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
43
docs/tutorial-basics/create-a-page.md
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Create a Page
|
||||
|
||||
Add **Markdown or React** files to `src/pages` to create a **standalone page**:
|
||||
|
||||
- `src/pages/index.js` → `localhost:3000/`
|
||||
- `src/pages/foo.md` → `localhost:3000/foo`
|
||||
- `src/pages/foo/bar.js` → `localhost:3000/foo/bar`
|
||||
|
||||
## Create your first React Page
|
||||
|
||||
Create a file at `src/pages/my-react-page.js`:
|
||||
|
||||
```jsx title="src/pages/my-react-page.js"
|
||||
import React from 'react';
|
||||
import Layout from '@theme/Layout';
|
||||
|
||||
export default function MyReactPage() {
|
||||
return (
|
||||
<Layout>
|
||||
<h1>My React page</h1>
|
||||
<p>This is a React page</p>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
A new page is now available at [http://localhost:3000/my-react-page](http://localhost:3000/my-react-page).
|
||||
|
||||
## Create your first Markdown Page
|
||||
|
||||
Create a file at `src/pages/my-markdown-page.md`:
|
||||
|
||||
```mdx title="src/pages/my-markdown-page.md"
|
||||
# My Markdown page
|
||||
|
||||
This is a Markdown page
|
||||
```
|
||||
|
||||
A new page is now available at [http://localhost:3000/my-markdown-page](http://localhost:3000/my-markdown-page).
|
||||
31
docs/tutorial-basics/deploy-your-site.md
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
# Deploy your site
|
||||
|
||||
Docusaurus is a **static-site-generator** (also called **[Jamstack](https://jamstack.org/)**).
|
||||
|
||||
It builds your site as simple **static HTML, JavaScript and CSS files**.
|
||||
|
||||
## Build your site
|
||||
|
||||
Build your site **for production**:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
The static files are generated in the `build` folder.
|
||||
|
||||
## Deploy your site
|
||||
|
||||
Test your production build locally:
|
||||
|
||||
```bash
|
||||
npm run serve
|
||||
```
|
||||
|
||||
The `build` folder is now served at [http://localhost:3000/](http://localhost:3000/).
|
||||
|
||||
You can now deploy the `build` folder **almost anywhere** easily, **for free** or very small cost (read the **[Deployment Guide](https://docusaurus.io/docs/deployment)**).
|
||||
152
docs/tutorial-basics/markdown-features.mdx
Normal file
@ -0,0 +1,152 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# Markdown Features
|
||||
|
||||
Docusaurus supports **[Markdown](https://daringfireball.net/projects/markdown/syntax)** and a few **additional features**.
|
||||
|
||||
## Front Matter
|
||||
|
||||
Markdown documents have metadata at the top called [Front Matter](https://jekyllrb.com/docs/front-matter/):
|
||||
|
||||
```text title="my-doc.md"
|
||||
// highlight-start
|
||||
---
|
||||
id: my-doc-id
|
||||
title: My document title
|
||||
description: My document description
|
||||
slug: /my-custom-url
|
||||
---
|
||||
// highlight-end
|
||||
|
||||
## Markdown heading
|
||||
|
||||
Markdown text with [links](./hello.md)
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
Regular Markdown links are supported, using url paths or relative file paths.
|
||||
|
||||
```md
|
||||
Let's see how to [Create a page](/create-a-page).
|
||||
```
|
||||
|
||||
```md
|
||||
Let's see how to [Create a page](./create-a-page.md).
|
||||
```
|
||||
|
||||
**Result:** Let's see how to [Create a page](./create-a-page.md).
|
||||
|
||||
## Images
|
||||
|
||||
Regular Markdown images are supported.
|
||||
|
||||
You can use absolute paths to reference images in the static directory (`static/img/docusaurus.png`):
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||

|
||||
|
||||
You can reference images relative to the current file as well. This is particularly useful to colocate images close to the Markdown files using them:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
## Code Blocks
|
||||
|
||||
Markdown code blocks are supported with Syntax highlighting.
|
||||
|
||||
````md
|
||||
```jsx title="src/components/HelloDocusaurus.js"
|
||||
function HelloDocusaurus() {
|
||||
return <h1>Hello, Docusaurus!</h1>;
|
||||
}
|
||||
```
|
||||
````
|
||||
|
||||
```jsx title="src/components/HelloDocusaurus.js"
|
||||
function HelloDocusaurus() {
|
||||
return <h1>Hello, Docusaurus!</h1>;
|
||||
}
|
||||
```
|
||||
|
||||
## Admonitions
|
||||
|
||||
Docusaurus has a special syntax to create admonitions and callouts:
|
||||
|
||||
```md
|
||||
:::tip My tip
|
||||
|
||||
Use this awesome feature option
|
||||
|
||||
:::
|
||||
|
||||
:::danger Take care
|
||||
|
||||
This action is dangerous
|
||||
|
||||
:::
|
||||
```
|
||||
|
||||
:::tip My tip
|
||||
|
||||
Use this awesome feature option
|
||||
|
||||
:::
|
||||
|
||||
:::danger Take care
|
||||
|
||||
This action is dangerous
|
||||
|
||||
:::
|
||||
|
||||
## MDX and React Components
|
||||
|
||||
[MDX](https://mdxjs.com/) can make your documentation more **interactive** and allows using any **React components inside Markdown**:
|
||||
|
||||
```jsx
|
||||
export const Highlight = ({children, color}) => (
|
||||
<span
|
||||
style={{
|
||||
backgroundColor: color,
|
||||
borderRadius: '20px',
|
||||
color: '#fff',
|
||||
padding: '10px',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
onClick={() => {
|
||||
alert(`You clicked the color ${color} with label ${children}`)
|
||||
}}>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
|
||||
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !
|
||||
|
||||
This is <Highlight color="#1877F2">Facebook blue</Highlight> !
|
||||
```
|
||||
|
||||
export const Highlight = ({children, color}) => (
|
||||
<span
|
||||
style={{
|
||||
backgroundColor: color,
|
||||
borderRadius: '20px',
|
||||
color: '#fff',
|
||||
padding: '10px',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
onClick={() => {
|
||||
alert(`You clicked the color ${color} with label ${children}`);
|
||||
}}>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
|
||||
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !
|
||||
|
||||
This is <Highlight color="#1877F2">Facebook blue</Highlight> !
|
||||
7
docs/tutorial-extras/_category_.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"label": "Tutorial - Extras",
|
||||
"position": 3,
|
||||
"link": {
|
||||
"type": "generated-index"
|
||||
}
|
||||
}
|
||||
BIN
docs/tutorial-extras/img/docsVersionDropdown.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
docs/tutorial-extras/img/localeDropdown.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
55
docs/tutorial-extras/manage-docs-versions.md
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Manage Docs Versions
|
||||
|
||||
Docusaurus can manage multiple versions of your docs.
|
||||
|
||||
## Create a docs version
|
||||
|
||||
Release a version 1.0 of your project:
|
||||
|
||||
```bash
|
||||
npm run docusaurus docs:version 1.0
|
||||
```
|
||||
|
||||
The `docs` folder is copied into `versioned_docs/version-1.0` and `versions.json` is created.
|
||||
|
||||
Your docs now have 2 versions:
|
||||
|
||||
- `1.0` at `http://localhost:3000/docs/` for the version 1.0 docs
|
||||
- `current` at `http://localhost:3000/docs/next/` for the **upcoming, unreleased docs**
|
||||
|
||||
## Add a Version Dropdown
|
||||
|
||||
To navigate seamlessly across versions, add a version dropdown.
|
||||
|
||||
Modify the `docusaurus.config.js` file:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
export default {
|
||||
themeConfig: {
|
||||
navbar: {
|
||||
items: [
|
||||
// highlight-start
|
||||
{
|
||||
type: 'docsVersionDropdown',
|
||||
},
|
||||
// highlight-end
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
The docs version dropdown appears in your navbar:
|
||||
|
||||

|
||||
|
||||
## Update an existing version
|
||||
|
||||
It is possible to edit versioned docs in their respective folder:
|
||||
|
||||
- `versioned_docs/version-1.0/hello.md` updates `http://localhost:3000/docs/hello`
|
||||
- `docs/hello.md` updates `http://localhost:3000/docs/next/hello`
|
||||
88
docs/tutorial-extras/translate-your-site.md
Normal file
@ -0,0 +1,88 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Translate your site
|
||||
|
||||
Let's translate `docs/intro.md` to French.
|
||||
|
||||
## Configure i18n
|
||||
|
||||
Modify `docusaurus.config.js` to add support for the `fr` locale:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
export default {
|
||||
i18n: {
|
||||
defaultLocale: 'en',
|
||||
locales: ['en', 'fr'],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## Translate a doc
|
||||
|
||||
Copy the `docs/intro.md` file to the `i18n/fr` folder:
|
||||
|
||||
```bash
|
||||
mkdir -p i18n/fr/docusaurus-plugin-content-docs/current/
|
||||
|
||||
cp docs/intro.md i18n/fr/docusaurus-plugin-content-docs/current/intro.md
|
||||
```
|
||||
|
||||
Translate `i18n/fr/docusaurus-plugin-content-docs/current/intro.md` in French.
|
||||
|
||||
## Start your localized site
|
||||
|
||||
Start your site on the French locale:
|
||||
|
||||
```bash
|
||||
npm run start -- --locale fr
|
||||
```
|
||||
|
||||
Your localized site is accessible at [http://localhost:3000/fr/](http://localhost:3000/fr/) and the `Getting Started` page is translated.
|
||||
|
||||
:::caution
|
||||
|
||||
In development, you can only use one locale at a time.
|
||||
|
||||
:::
|
||||
|
||||
## Add a Locale Dropdown
|
||||
|
||||
To navigate seamlessly across languages, add a locale dropdown.
|
||||
|
||||
Modify the `docusaurus.config.js` file:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
export default {
|
||||
themeConfig: {
|
||||
navbar: {
|
||||
items: [
|
||||
// highlight-start
|
||||
{
|
||||
type: 'localeDropdown',
|
||||
},
|
||||
// highlight-end
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
The locale dropdown now appears in your navbar:
|
||||
|
||||

|
||||
|
||||
## Build your localized site
|
||||
|
||||
Build your site for a specific locale:
|
||||
|
||||
```bash
|
||||
npm run build -- --locale fr
|
||||
```
|
||||
|
||||
Or build your site to include all the locales at once:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
150
docusaurus.config.js
Normal file
@ -0,0 +1,150 @@
|
||||
// @ts-check
|
||||
// `@type` JSDoc annotations allow editor autocompletion and type checking
|
||||
// (when paired with `@ts-check`).
|
||||
// There are various equivalent ways to declare your Docusaurus config.
|
||||
// See: https://docusaurus.io/docs/api/docusaurus-config
|
||||
|
||||
import {themes as prismThemes} from 'prism-react-renderer';
|
||||
|
||||
/** @type {import('@docusaurus/types').Config} */
|
||||
const config = {
|
||||
title: 'Cloudtopiaa Documentation',
|
||||
tagline: 'Your cloud partner',
|
||||
favicon: 'img/Cloudtopiaa white.jpg',
|
||||
|
||||
// Set the production url of your site here
|
||||
url: 'https://your-docusaurus-site.example.com',
|
||||
// Set the /<baseUrl>/ pathname under which your site is served
|
||||
// For GitHub pages deployment, it is often '/<projectName>/'
|
||||
baseUrl: '/',
|
||||
|
||||
// GitHub pages deployment config.
|
||||
// If you aren't using GitHub pages, you don't need these.
|
||||
// organizationName: 'facebook', // Usually your GitHub org/user name.
|
||||
// projectName: 'docusaurus', // Usually your repo name.
|
||||
|
||||
// onBrokenLinks: 'throw',
|
||||
// onBrokenMarkdownLinks: 'warn',
|
||||
|
||||
// Even if you don't use internationalization, you can use this field to set
|
||||
// useful metadata like html lang. For example, if your site is Chinese, you
|
||||
// may want to replace "en" with "zh-Hans".
|
||||
i18n: {
|
||||
defaultLocale: 'en',
|
||||
locales: ['en'],
|
||||
},
|
||||
|
||||
presets: [
|
||||
[
|
||||
'classic',
|
||||
/** @type {import('@docusaurus/preset-classic').Options} */
|
||||
({
|
||||
docs: {
|
||||
sidebarPath: './sidebars.js',
|
||||
// Please change this to your repo.
|
||||
// Remove this to remove the "edit this page" links.
|
||||
// editUrl:
|
||||
// 'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
|
||||
},
|
||||
blog: {
|
||||
showReadingTime: true,
|
||||
feedOptions: {
|
||||
type: ['rss', 'atom'],
|
||||
xslt: true,
|
||||
},
|
||||
// Please change this to your repo.
|
||||
// Remove this to remove the "edit this page" links.
|
||||
// editUrl:
|
||||
// 'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
|
||||
// // Useful options to enforce blogging best practices
|
||||
onInlineTags: 'warn',
|
||||
onInlineAuthors: 'warn',
|
||||
onUntruncatedBlogPosts: 'warn',
|
||||
},
|
||||
theme: {
|
||||
customCss: './src/css/custom.css',
|
||||
},
|
||||
}),
|
||||
],
|
||||
],
|
||||
|
||||
themeConfig:
|
||||
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
||||
({
|
||||
// Replace with your project's social card
|
||||
image: 'img/docusaurus-social-card.jpg',
|
||||
navbar: {
|
||||
title: 'Cloudtopiaa',
|
||||
logo: {
|
||||
alt: 'Cloudtopiaa Logo',
|
||||
src: 'img/logo.svg',
|
||||
srcDark:'img/Dark-Logo.png',
|
||||
},
|
||||
items: [
|
||||
{
|
||||
type: 'docSidebar',
|
||||
sidebarId: 'tutorialSidebar',
|
||||
position: 'left',
|
||||
label: 'Tutorial',
|
||||
},
|
||||
{to: '/blog', label: 'Blog', position: 'left'},
|
||||
// {
|
||||
// href: 'https://github.com/facebook/docusaurus',
|
||||
// label: 'GitHub',
|
||||
// position: 'right',
|
||||
// },
|
||||
],
|
||||
},
|
||||
footer: {
|
||||
style: 'dark',
|
||||
links: [
|
||||
{
|
||||
// title: 'Docs',
|
||||
// items: [
|
||||
// {
|
||||
// label: 'Tutorial',
|
||||
// to: '/docs/intro',
|
||||
// },
|
||||
// ],
|
||||
},
|
||||
// {
|
||||
// title: 'Community',
|
||||
// items: [
|
||||
// {
|
||||
// // label: 'Stack Overflow',
|
||||
// // href: 'https://stackoverflow.com/questions/tagged/docusaurus',
|
||||
// },
|
||||
// {
|
||||
// // label: 'Discord',
|
||||
// // href: 'https://discordapp.com/invite/docusaurus',
|
||||
// },
|
||||
// {
|
||||
// // label: 'Twitter',
|
||||
// // href: 'https://twitter.com/docusaurus',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// title: 'More',
|
||||
// items: [
|
||||
// {
|
||||
// // label: 'Blog',
|
||||
// // to: '/blog',
|
||||
// },
|
||||
// {
|
||||
// // label: 'GitHub',
|
||||
// // href: 'https://github.com/facebook/docusaurus',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
],
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Tech4biz Solutions.`,
|
||||
},
|
||||
prism: {
|
||||
theme: prismThemes.github,
|
||||
darkTheme: prismThemes.dracula,
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
export default config;
|
||||
15859
package-lock.json
generated
Normal file
44
package.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "my-website",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"docusaurus": "docusaurus",
|
||||
"start": "docusaurus start",
|
||||
"build": "docusaurus build",
|
||||
"swizzle": "docusaurus swizzle",
|
||||
"deploy": "docusaurus deploy",
|
||||
"clear": "docusaurus clear",
|
||||
"serve": "docusaurus serve",
|
||||
"write-translations": "docusaurus write-translations",
|
||||
"write-heading-ids": "docusaurus write-heading-ids"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "^3.5.2",
|
||||
"@docusaurus/preset-classic": "^3.5.2",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
"clsx": "^2.0.0",
|
||||
"prism-react-renderer": "^2.3.0",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@docusaurus/module-type-aliases": "3.5.2",
|
||||
"@docusaurus/types": "3.5.2"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.5%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 3 chrome version",
|
||||
"last 3 firefox version",
|
||||
"last 5 safari version"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0"
|
||||
}
|
||||
}
|
||||
44
sidebars.js
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Creating a sidebar enables you to:
|
||||
- create an ordered group of docs
|
||||
- render a sidebar for each doc of that group
|
||||
- provide next/previous navigation
|
||||
|
||||
The sidebars can be generated from the filesystem, or explicitly defined here.
|
||||
|
||||
Create as many sidebars as you want.
|
||||
*/
|
||||
|
||||
// @ts-check
|
||||
|
||||
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
||||
const sidebars = {
|
||||
// By default, Docusaurus generates a sidebar from the docs folder structure
|
||||
//tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
|
||||
|
||||
// But you can create a sidebar manually
|
||||
|
||||
tutorialSidebar: [
|
||||
//'intro',
|
||||
//'hello',
|
||||
{
|
||||
type: 'category',
|
||||
label: 'User Guide',
|
||||
items: [
|
||||
'CloudtopiaaInstances/Preface',
|
||||
'CloudtopiaaInstances/Manage Key Pairs',
|
||||
'CloudtopiaaInstances/Manage Images',
|
||||
'CloudtopiaaInstances/Manage Network',
|
||||
'CloudtopiaaInstances/Manage Instances',
|
||||
'CloudtopiaaInstances/Manage Load Balancers',
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
};
|
||||
|
||||
export default sidebars;
|
||||
60
src/components/CodeBloack.js
Normal file
@ -0,0 +1,60 @@
|
||||
// import React from 'react';
|
||||
|
||||
// const CodeEditor = () => {
|
||||
// const copyCode = () => {
|
||||
// const codeElement = document.getElementById('code-snippet');
|
||||
// navigator.clipboard.writeText(codeElement.innerText)
|
||||
// .then(() => {
|
||||
// alert('Code copied to clipboard!');
|
||||
// })
|
||||
// .catch(err => {
|
||||
// console.error('Failed to copy: ', err);
|
||||
// });
|
||||
// };
|
||||
|
||||
// return (
|
||||
// <div className="code-editor">
|
||||
// <pre>
|
||||
// <code id="code-snippet">
|
||||
// {`class Painter:
|
||||
// def color_shape(self, shape):
|
||||
// # Code for coloring the shape
|
||||
// pass`}
|
||||
// </code>
|
||||
// </pre>
|
||||
// <button className="copy-btn" onClick={copyCode}>
|
||||
// Copy Code
|
||||
// </button>
|
||||
// </div>
|
||||
// );
|
||||
// };
|
||||
|
||||
// export default CodeEditor;
|
||||
|
||||
// src/components/CodeBlock.js
|
||||
import React from 'react';
|
||||
|
||||
const CodeBlock = ({ code }) => {
|
||||
const copyCode = () => {
|
||||
navigator.clipboard.writeText(code)
|
||||
.then(() => {
|
||||
alert('Code copied to clipboard!');
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to copy: ', err);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="code-editor">
|
||||
<pre>
|
||||
<code>{code}</code>
|
||||
</pre>
|
||||
<button className="copy-btn" onClick={copyCode}>
|
||||
Copy Code
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CodeBlock;
|
||||
194
src/components/HomepageFeatures/index.js
Normal file
@ -0,0 +1,194 @@
|
||||
import clsx from 'clsx';
|
||||
import Heading from '@theme/Heading';
|
||||
import styles from './styles.module.css';
|
||||
|
||||
// const FeatureList = [
|
||||
// {
|
||||
// title: 'Easy to Use',
|
||||
// Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
|
||||
// description: (
|
||||
// <>
|
||||
// Docusaurus was designed from the ground up to be easily installed and
|
||||
// used to get your website up and running quickly.
|
||||
// </>
|
||||
// ),
|
||||
// },
|
||||
// {
|
||||
// title: 'Focus on What Matters',
|
||||
// Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
|
||||
// description: (
|
||||
// <>
|
||||
// Docusaurus lets you focus on your docs, and we'll do the chores. Go
|
||||
// ahead and move your docs into the <code>docs</code> directory.
|
||||
// </>
|
||||
// ),
|
||||
// },
|
||||
// {
|
||||
// title: 'Powered by React',
|
||||
// Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
|
||||
// description: (
|
||||
// <>
|
||||
// Extend or customize your website layout by reusing React. Docusaurus can
|
||||
// be extended while reusing the same header and footer.
|
||||
// </>
|
||||
// ),
|
||||
// },
|
||||
// ];
|
||||
|
||||
// function Feature({Svg, title, description}) {
|
||||
// return (
|
||||
// <div className={clsx('col col--4')}>
|
||||
// <div className="text--center">
|
||||
// <Svg className={styles.featureSvg} role="img" />
|
||||
// </div>
|
||||
// <div className="text--center padding-horiz--md">
|
||||
// <Heading as="h3">{title}</Heading>
|
||||
// <p>{description}</p>
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
|
||||
// export default function HomepageFeatures() {
|
||||
// return (
|
||||
// <section className={styles.features}>
|
||||
// <div className="container">
|
||||
// <div className="row">
|
||||
// {FeatureList.map((props, idx) => (
|
||||
// <Feature key={idx} {...props} />
|
||||
// ))}
|
||||
// </div>
|
||||
// </div>
|
||||
// </section>
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
// const FeatureList = [
|
||||
// {
|
||||
// title: 'Developer-Friendly',
|
||||
// Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
|
||||
// description: (
|
||||
// <>
|
||||
// Cloudtopiaa Cloud is designed with developers in mind, offering a seamless
|
||||
// and intuitive environment for building, scaling, and managing cloud infrastructure.
|
||||
// Get started quickly with our comprehensive reference materials and documentation.
|
||||
// </>
|
||||
// ),
|
||||
// },
|
||||
// {
|
||||
// title: 'Focus on Cloud Solutions',
|
||||
// Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
|
||||
// description: (
|
||||
// <>
|
||||
// Cloudtopiaa Cloud allows you to focus on building innovative cloud solutions while
|
||||
// we handle the infrastructure. Explore our in-depth docs and API references for
|
||||
// managing instances, storage, and network configurations.
|
||||
// </>
|
||||
// ),
|
||||
// },
|
||||
// {
|
||||
// title: 'Powered by Robust Infrastructure',
|
||||
// Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
|
||||
// description: (
|
||||
// <>
|
||||
// Built on a scalable infrastructure, Cloudtopiaa Cloud enables you to deploy and manage
|
||||
// cloud services with ease. Leverage the power of our platform with custom solutions
|
||||
// and extensive reference guides.
|
||||
// </>
|
||||
// ),
|
||||
// },
|
||||
// ];
|
||||
|
||||
// function Feature({Svg, title, description}) {
|
||||
// return (
|
||||
// <div className={clsx('col col--4')}>
|
||||
// <div className="text--center">
|
||||
// <Svg className={styles.featureSvg} role="img" />
|
||||
// </div>
|
||||
// <div className="text--center padding-horiz--md">
|
||||
// <h3>{title}</h3>
|
||||
// <p>{description}</p>
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
|
||||
// export default function HomepageFeatures() {
|
||||
// return (
|
||||
// <section className={styles.features}>
|
||||
// <div className="container">
|
||||
// <div className="row">
|
||||
// {FeatureList.map((props, idx) => (
|
||||
// <Feature key={idx} {...props} />
|
||||
// ))}
|
||||
// </div>
|
||||
// </div>
|
||||
// </section>
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
const FeatureList = [
|
||||
{
|
||||
title: 'Explore Technical Tutorials',
|
||||
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
|
||||
description: (
|
||||
<>
|
||||
If you're looking to understand how to technically implement and use Cloudtopiaa Cloud,
|
||||
head over to the <strong>Tutorials</strong> section. Our detailed guides will help you
|
||||
set up, configure, and optimize your cloud infrastructure step by step.
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Stay Updated with Latest Blogs',
|
||||
Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
|
||||
description: (
|
||||
<>
|
||||
To stay on top of the latest updates, tips, and best practices for using Cloudtopiaa Cloud,
|
||||
check out our <strong>Cloudtopiaa Blogs</strong> section. You'll find expert advice and
|
||||
insights that keep you informed on the newest trends and features.
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Reference Documentation',
|
||||
Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
|
||||
description: (
|
||||
<>
|
||||
Need detailed documentation? Visit our <strong>Docs</strong> section to find in-depth
|
||||
reference material on using Cloudtopiaa Cloud's API, instance management, and much more.
|
||||
Everything you need to know to get the most out of the platform is available there.
|
||||
</>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
function Feature({Svg, title, description}) {
|
||||
return (
|
||||
<div className={clsx('col col--4')}>
|
||||
<div className="text--center">
|
||||
<Svg className={styles.featureSvg} role="img" />
|
||||
</div>
|
||||
<div className="text--center padding-horiz--md">
|
||||
<h3>{title}</h3>
|
||||
<p>{description}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function HomepageFeatures() {
|
||||
return (
|
||||
<section className={styles.features}>
|
||||
<div className="container">
|
||||
<div className="row">
|
||||
{FeatureList.map((props, idx) => (
|
||||
<Feature key={idx} {...props} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
11
src/components/HomepageFeatures/styles.module.css
Normal file
@ -0,0 +1,11 @@
|
||||
.features {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 2rem 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.featureSvg {
|
||||
height: 200px;
|
||||
width: 200px;
|
||||
}
|
||||
176
src/css/custom.css
Normal file
@ -0,0 +1,176 @@
|
||||
/**
|
||||
* Any CSS included here will be global. The classic template
|
||||
* bundles Infima by default. Infima is a CSS framework designed to
|
||||
* work well for content-centric websites.
|
||||
*/
|
||||
|
||||
/* You can override the default Infima variables here. */
|
||||
|
||||
@import url('https://fonts.googleapis.com/css?family=Muli&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css?family=Quicksand&display=swap');
|
||||
|
||||
|
||||
:root {
|
||||
--ifm-color-primary: #384cdc;
|
||||
--ifm-color-primary-dark: #384cdc;
|
||||
--ifm-color-primary-darker: #384cdc;
|
||||
--ifm-color-primary-darkest: #384cdc;
|
||||
--ifm-color-primary-light: #384cdc;
|
||||
--ifm-color-primary-lighter: #384cdc;
|
||||
--ifm-color-primary-lightest: #384cdc;
|
||||
--ifm-code-font-size: 95%;
|
||||
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* For readability concerns, you should choose a lighter palette in dark mode. */
|
||||
[data-theme='dark'] {
|
||||
--ifm-color-primary: #384cdc;
|
||||
--ifm-color-primary-dark: #384cdc;
|
||||
--ifm-color-primary-darker: #384cdc;
|
||||
--ifm-color-primary-darkest: #384cdc;
|
||||
--ifm-color-primary-light: #384cdc;
|
||||
--ifm-color-primary-lighter: #384cdc;
|
||||
--ifm-color-primary-lightest: #384cdc;
|
||||
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.custom-text {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
font-family: Open Sans;
|
||||
}
|
||||
|
||||
|
||||
/* code-editor section */
|
||||
.code-editor {
|
||||
position: relative;
|
||||
padding: 20px;
|
||||
padding-bottom: 5px;
|
||||
background-color: #212020;
|
||||
border-radius: 10px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.copy-btn{
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
background-color: #3c3c3c;
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
/* text section */
|
||||
|
||||
.main-head{
|
||||
font-size: 40px;
|
||||
font-family: poppins;
|
||||
font-weight: 700;
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
.head {
|
||||
margin-top: 40px;
|
||||
font-size: 34px;
|
||||
font-family: Open Sans;
|
||||
font-weight: 400;
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
.text{
|
||||
margin-top: 10px;
|
||||
font-size: 18px;
|
||||
font-family: Open Sans;
|
||||
font-weight: 400;
|
||||
|
||||
}
|
||||
|
||||
.con {
|
||||
font-size: 40px;
|
||||
font-family: Open Sans;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.note {
|
||||
background-color: #384cdc;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #384cdc;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
font-family: Open Sans;
|
||||
font-weight: 400;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.blue{
|
||||
color: blue;
|
||||
background-color: #d9d9d9;
|
||||
padding: 2px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.warn{
|
||||
color: #ffffff;
|
||||
background-color: #ff1a1a;
|
||||
padding: 2px;
|
||||
font-family: Open Sans;
|
||||
font-weight: 400;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.hint{
|
||||
background-color: #6296e4;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #6296e4;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
font-family: Open Sans;
|
||||
font-weight: 400;
|
||||
margin-left: 20px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* browser-support-table */
|
||||
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
|
||||
}
|
||||
|
||||
th, td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
font-family: Open Sans;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #2c4b75; /* Dark blue */
|
||||
color: white;
|
||||
}
|
||||
|
||||
tr:nth-child(even) {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
/* tr:hover {
|
||||
background-color: #ddd;
|
||||
} */
|
||||
|
||||
td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
43
src/pages/index.js
Normal file
@ -0,0 +1,43 @@
|
||||
import clsx from 'clsx';
|
||||
import Link from '@docusaurus/Link';
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
import Layout from '@theme/Layout';
|
||||
import HomepageFeatures from '@site/src/components/HomepageFeatures';
|
||||
|
||||
import Heading from '@theme/Heading';
|
||||
import styles from './index.module.css';
|
||||
|
||||
function HomepageHeader() {
|
||||
const {siteConfig} = useDocusaurusContext();
|
||||
return (
|
||||
<header className={clsx('hero hero--primary', styles.heroBanner)}>
|
||||
<div className="container">
|
||||
<Heading as="h1" className="hero__title">
|
||||
{siteConfig.title}
|
||||
</Heading>
|
||||
<p className="hero__subtitle">{siteConfig.tagline}</p>
|
||||
<div className={styles.buttons}>
|
||||
{/* <Link
|
||||
className="button button--secondary button--lg"
|
||||
to="/docs/intro">
|
||||
Docusaurus Tutorial - 5min ⏱️
|
||||
</Link> */}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
const {siteConfig} = useDocusaurusContext();
|
||||
return (
|
||||
<Layout
|
||||
title={`${siteConfig.title}`}
|
||||
description="Description will go into a meta tag in <head />">
|
||||
<HomepageHeader />
|
||||
<main>
|
||||
<HomepageFeatures />
|
||||
</main>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
23
src/pages/index.module.css
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* CSS files with the .module.css suffix will be treated as CSS modules
|
||||
* and scoped locally.
|
||||
*/
|
||||
|
||||
.heroBanner {
|
||||
padding: 4rem 0;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 996px) {
|
||||
.heroBanner {
|
||||
padding: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
7
src/pages/markdown-page.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Markdown page example
|
||||
---
|
||||
|
||||
# Markdown page example
|
||||
|
||||
You don't need React to write simple standalone pages.
|
||||
3
src/pages/my-markdown-page.md
Normal file
@ -0,0 +1,3 @@
|
||||
# My Markdown page
|
||||
|
||||
This is a Markdown page
|
||||
11
src/pages/my-react-page.js
Normal file
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import Layout from '@theme/Layout';
|
||||
|
||||
export default function MyReactPage() {
|
||||
return (
|
||||
<Layout>
|
||||
<h1>My React page</h1>
|
||||
<p>This is a React page</p>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
0
static/.nojekyll
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
static/img/360_F_329545913_DjGMeVFl3r78coNEXel3w9r3OSJhcGGf.jpg
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
static/img/Cloudtopiaa white.jpg
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
static/img/Dark-Logo.png
Normal file
|
After Width: | Height: | Size: 137 KiB |
BIN
static/img/LampStack.jpg
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
static/img/S-G01.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
static/img/add-rule.png
Normal file
|
After Width: | Height: | Size: 128 KiB |
BIN
static/img/argocd_app_drill.png
Normal file
|
After Width: | Height: | Size: 333 KiB |
BIN
static/img/argocd_app_of.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
static/img/argocd_app_of_apps.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
static/img/argocd_apps.png
Normal file
|
After Width: | Height: | Size: 632 KiB |
BIN
static/img/argocd_apps_sync_progress.png
Normal file
|
After Width: | Height: | Size: 643 KiB |
BIN
static/img/argocd_apps_sync_webui.png
Normal file
|
After Width: | Height: | Size: 567 KiB |
BIN
static/img/argocd_autosync_prune.png
Normal file
|
After Width: | Height: | Size: 264 KiB |
BIN
static/img/argocd_failed_app.png
Normal file
|
After Width: | Height: | Size: 536 KiB |
BIN
static/img/argocd_failed_app_investigation.png
Normal file
|
After Width: | Height: | Size: 513 KiB |